/*
 * File: Ctrl.cpp
 *
 * Code generated for Simulink model 'Ctrl'.
 *
 * Model version                  : 1.559
 * Simulink Coder version         : 8.2 (R2012a) 29-Dec-2011
 * TLC version                    : 8.2 (Dec 29 2011)
 * C/C++ source code generated on : Wed Jun 27 17:36:40 2012
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Texas Instruments->C2000
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "Ctrl.h"
#include "Ctrl_private.h"

/* Named constants for Chart: '<S1>/Chart' */
#define Ctrl_IN_AltMode                ((uint8_T)1U)
#define Ctrl_IN_AutoMode               ((uint8_T)2U)
#define Ctrl_IN_Failed                 ((uint8_T)1U)
#define Ctrl_IN_NO_ACTIVE_CHILD        ((uint8_T)0U)
#define Ctrl_IN_Off                    ((uint8_T)3U)
#define Ctrl_IN_Online                 ((uint8_T)2U)
#define Ctrl_IN_RateMode               ((uint8_T)4U)
#define Ctrl_IN_RollPitchMode          ((uint8_T)5U)

real32_T look1_iflf_binlxpw(real32_T u0, const real32_T bp0[], const real32_T
  table[], uint32_T maxIndex)
{
  real32_T frac;
  uint32_T iRght;
  uint32_T iLeft;
  uint32_T bpIdx;

  /* Lookup 1-D
     Search method: 'binary'
     Use previous index: 'off'
     Interpolation method: 'Linear'
     Extrapolation method: 'Linear'
     Use last breakpoint for index at or above upper limit: 'off'
     Remove protection against out-of-range input in generated code: 'off'
   */
  /* Prelookup - Index and Fraction
     Index Search method: 'binary'
     Extrapolation method: 'Linear'
     Use previous index: 'off'
     Use last breakpoint for index at or above upper limit: 'off'
     Remove protection against out-of-range input in generated code: 'off'
   */
  if (u0 <= bp0[0UL]) {
    iLeft = 0UL;
    frac = (u0 - bp0[0UL]) / (bp0[1UL] - bp0[0UL]);
  } else if (u0 < bp0[maxIndex]) {
    /* Binary Search */
    bpIdx = maxIndex >> 1UL;
    iLeft = 0UL;
    iRght = maxIndex;
    while (iRght - iLeft > 1UL) {
      if (u0 < bp0[bpIdx]) {
        iRght = bpIdx;
      } else {
        iLeft = bpIdx;
      }

      bpIdx = (iRght + iLeft) >> 1UL;
    }

    frac = (u0 - bp0[iLeft]) / (bp0[iLeft + 1UL] - bp0[iLeft]);
  } else {
    iLeft = maxIndex - 1UL;
    frac = (u0 - bp0[maxIndex - 1UL]) / (bp0[maxIndex] - bp0[maxIndex - 1UL]);
  }

  /* Interpolation 1-D
     Interpolation method: 'Linear'
     Use last breakpoint for index at or above upper limit: 'off'
     Overflow mode: 'portable wrapping'
   */
  return (table[iLeft + 1UL] - table[iLeft]) * frac + table[iLeft];
}

/*
 * Output and update for atomic system:
 *    '<S17>/Correct Yaw'
 *    '<S41>/Correct Yaw'
 */
void Ctrl_CorrectYaw(real32_T rtu_u, rtB_CorrectYaw_Ctrl *localB)
{
  /* MATLAB Function 'Ctrl/AltCtrl/Yaw Controller/Correct Yaw': '<S30>:1' */
  /* '<S30>:1:3' */
  localB->y = rtu_u / 6.28318548F;
  localB->y = (localB->y - (real32_T)floor(localB->y)) * 6.28318548F;
  if ((real_T)localB->y > 3.1415926535897931) {
    /* '<S30>:1:4' */
    /* '<S30>:1:5' */
    localB->y -= 6.28318548F;
  }
}

/* Function for Chart: '<S1>/Chart' */
void CtrlModelClass::Ctrl_SetOutputs(uint32_T state)
{
  /* Graphical Function 'SetOutputs': '<S6>:21' */
  /* Transition: '<S6>:35' */
  /* Transition: '<S6>:36' */
  /*  All Off */
  Ctrl_B.CtrlOff = FALSE;
  Ctrl_B.CtrlRate = FALSE;
  Ctrl_B.CtrlRollPitch = FALSE;
  Ctrl_B.CtrlAlt = FALSE;
  Ctrl_B.CtrlAuto = FALSE;
  if (state == 0UL) {
    /* Transition: '<S6>:38' */
    /* Transition: '<S6>:43' */
    /*  Off */
    Ctrl_B.CtrlOff = TRUE;

    /* Transition: '<S6>:47' */
  } else if (state == 3UL) {
    /* Transition: '<S6>:128' */
    /* Transition: '<S6>:127' */
    /*  Alt Control */
    Ctrl_B.CtrlAlt = TRUE;

    /* Transition: '<S6>:130' */
  } else if (state == 2UL) {
    /* Transition: '<S6>:96' */
    /* Transition: '<S6>:93' */
    /*  RollPitch Control */
    Ctrl_B.CtrlRollPitch = TRUE;

    /* Transition: '<S6>:95' */
  } else if (state == 1UL) {
    /* Transition: '<S6>:40' */
    /* Transition: '<S6>:42' */
    /*  Rate Control */
    Ctrl_B.CtrlRate = TRUE;

    /* Transition: '<S6>:49' */
  } else {
    if (state == 4UL) {
      /* Transition: '<S6>:138' */
      /* Transition: '<S6>:136' */
      /*  Auto Control */
      Ctrl_B.CtrlAuto = TRUE;

      /* Transition: '<S6>:137' */
    }
  }
}

/* Model step function */
void CtrlModelClass::step()
{
  /* local block i/o variables */
  real32_T rtb_Sum1;
  real32_T rtb_Sum1_h;
  static const real32_T Q[4] = { 1.64024994E-9F, 3.2805E-7F, 3.2805E-7F,
    6.561E-5F };

  static const real32_T A[4] = { 1.0F, 0.0F, 0.01F, 1.0F };

  real32_T rtb_y;
  real32_T rtb_AltFilt;
  real32_T rtb_VertSpeed;
  int32_T cff;
  int32_T j;
  real32_T rtb_Bias2;
  real32_T rtb_Bias;
  real32_T rtb_Bias1;
  real32_T rtb_Add6_g;
  real32_T rtb_FilterCoefficient_p;
  real32_T rtb_Saturation_i;
  real32_T rtb_IntegralGain_e;
  real32_T rtb_FilterCoefficient_e4;
  real32_T rtb_IntegralGain_oq;
  real32_T rtb_FilterCoefficient_at;
  real32_T rtb_Sum_am;
  real32_T rtb_Saturation_a;
  real32_T rtb_FilterCoefficient_ox;
  real32_T rtb_Add4_e;
  real32_T rtb_IntegralGain_p0;
  real32_T rtb_Sum_p;
  real32_T rtb_Saturation_kd;
  real32_T rtb_Scaleyaw_o;
  real32_T rtb_Add5_m;
  real32_T rtb_Add3_f;
  real32_T rtb_DLookupTable_l;
  real32_T A_0[4];
  int16_T i;
  real32_T I[4];
  real32_T Kk_idx;
  real32_T Kk_idx_0;

  /* Outputs for Atomic SubSystem: '<Root>/Ctrl' */
  /* MATLAB Function: '<S2>/Embedded MATLAB Function2' incorporates:
   *  Inport: '<Root>/PressureAbs'
   *  MATLAB Function: '<S11>/MATLAB Function'
   */
  /* MATLAB Function 'Ctrl/AltCalculator/Subsystem/MATLAB Function': '<S12>:1' */
  /* '<S12>:1:3' */
  /* MATLAB Function 'Ctrl/AltCalculator/Embedded MATLAB Function2': '<S10>:1' */
  /*  X1=position (s) */
  /*  X2=velocity (v) */
  /* '<S10>:1:13' */
  /*  process noise (0.81m/s^2 acc error) */
  /* '<S10>:1:14' */
  /*  measurement noise (0.5m error) */
  /*  calculate */
  /*  assume zero acc */
  /*  time update */
  /* '<S10>:1:24' */
  Kk_idx = Ctrl_DWork.Xk[1];
  Ctrl_DWork.Xk[0] += 0.01F * Ctrl_DWork.Xk[1];
  Ctrl_DWork.Xk[1] = Kk_idx;

  /* '<S10>:1:25' */
  for (i = 0; i < 2; i++) {
    A_0[i] = 0.0F;
    A_0[i] += A[i] * Ctrl_DWork.Pk[0];
    A_0[i] += A[i + 2] * Ctrl_DWork.Pk[1];
    A_0[i + 2] = 0.0F;
    A_0[i + 2] += A[i] * Ctrl_DWork.Pk[2];
    A_0[i + 2] += A[i + 2] * Ctrl_DWork.Pk[3];
  }

  for (i = 0; i < 2; i++) {
    Ctrl_DWork.Pk[i] = (A_0[i + 2] * 0.01F + A_0[i]) + Q[i];
    Ctrl_DWork.Pk[i + 2] = A_0[i + 2] + Q[i + 2];
  }

  /*  measurement update */
  /* '<S10>:1:29' */
  Kk_idx = Ctrl_DWork.Pk[0] / (Ctrl_DWork.Pk[0] + 0.25F);
  Kk_idx_0 = Ctrl_DWork.Pk[1] / (Ctrl_DWork.Pk[0] + 0.25F);

  /* '<S10>:1:30' */
  rtb_Bias1 = (1.0F - (real32_T)pow(Ctrl_U.PressureAbs / 101325.0F, 0.190294951F))
    * 44330.0F - Ctrl_DWork.Xk[0];
  Ctrl_DWork.Xk[0] += Kk_idx * rtb_Bias1;
  Ctrl_DWork.Xk[1] += Kk_idx_0 * rtb_Bias1;

  /* '<S10>:1:31' */
  A_0[0] = 1.0F - Kk_idx;
  A_0[1] = 0.0F - Kk_idx_0;
  A_0[2] = 0.0F;
  A_0[3] = 1.0F;
  for (i = 0; i < 2; i++) {
    I[i] = 0.0F;
    I[i] += A_0[i] * Ctrl_DWork.Pk[0];
    I[i] += A_0[i + 2] * Ctrl_DWork.Pk[1];
    I[i + 2] = 0.0F;
    I[i + 2] += A_0[i] * Ctrl_DWork.Pk[2];
    I[i + 2] += A_0[i + 2] * Ctrl_DWork.Pk[3];
  }

  Ctrl_DWork.Pk[0] = I[0];
  Ctrl_DWork.Pk[1] = I[1];
  Ctrl_DWork.Pk[2] = I[2];
  Ctrl_DWork.Pk[3] = I[3];

  /* '<S10>:1:32' */
  rtb_AltFilt = Ctrl_DWork.Xk[0];

  /* '<S10>:1:33' */
  rtb_VertSpeed = Ctrl_DWork.Xk[1];

  /* End of MATLAB Function: '<S2>/Embedded MATLAB Function2' */

  /* DiscreteFir: '<S4>/Discrete FIR Filter' incorporates:
   *  Inport: '<Root>/MagXYZ'
   */
  rtb_Saturation_i = Ctrl_U.MagXYZ[0] * Ctrl_P.DiscreteFIRFilter_Coefficients[0];
  cff = 1L;
  for (j = Ctrl_DWork.DiscreteFIRFilter_circBuf; j < 9L; j++) {
    rtb_Saturation_i += Ctrl_DWork.DiscreteFIRFilter_states[j] *
      Ctrl_P.DiscreteFIRFilter_Coefficients[cff];
    cff++;
  }

  for (j = 0L; j < Ctrl_DWork.DiscreteFIRFilter_circBuf; j++) {
    rtb_Saturation_i += Ctrl_DWork.DiscreteFIRFilter_states[j] *
      Ctrl_P.DiscreteFIRFilter_Coefficients[cff];
    cff++;
  }

  /* End of DiscreteFir: '<S4>/Discrete FIR Filter' */

  /* Bias: '<S4>/Bias2' */
  rtb_Bias2 = rtb_Saturation_i + Ctrl_P.Bias2_Bias;

  /* DiscreteFir: '<S4>/Discrete FIR Filter1' incorporates:
   *  Inport: '<Root>/MagXYZ'
   */
  rtb_Saturation_i = Ctrl_U.MagXYZ[1] * Ctrl_P.DiscreteFIRFilter1_Coefficients[0];
  cff = 1L;
  for (j = Ctrl_DWork.DiscreteFIRFilter1_circBuf; j < 9L; j++) {
    rtb_Saturation_i += Ctrl_DWork.DiscreteFIRFilter1_states[j] *
      Ctrl_P.DiscreteFIRFilter1_Coefficients[cff];
    cff++;
  }

  for (j = 0L; j < Ctrl_DWork.DiscreteFIRFilter1_circBuf; j++) {
    rtb_Saturation_i += Ctrl_DWork.DiscreteFIRFilter1_states[j] *
      Ctrl_P.DiscreteFIRFilter1_Coefficients[cff];
    cff++;
  }

  /* End of DiscreteFir: '<S4>/Discrete FIR Filter1' */

  /* Bias: '<S4>/Bias' */
  rtb_Bias = rtb_Saturation_i + Ctrl_P.Bias_Bias;

  /* DiscreteFir: '<S4>/Discrete FIR Filter2' incorporates:
   *  Inport: '<Root>/MagXYZ'
   */
  rtb_Saturation_i = Ctrl_U.MagXYZ[2] * Ctrl_P.DiscreteFIRFilter2_Coefficients[0];
  cff = 1L;
  for (j = Ctrl_DWork.DiscreteFIRFilter2_circBuf; j < 9L; j++) {
    rtb_Saturation_i += Ctrl_DWork.DiscreteFIRFilter2_states[j] *
      Ctrl_P.DiscreteFIRFilter2_Coefficients[cff];
    cff++;
  }

  for (j = 0L; j < Ctrl_DWork.DiscreteFIRFilter2_circBuf; j++) {
    rtb_Saturation_i += Ctrl_DWork.DiscreteFIRFilter2_states[j] *
      Ctrl_P.DiscreteFIRFilter2_Coefficients[cff];
    cff++;
  }

  /* End of DiscreteFir: '<S4>/Discrete FIR Filter2' */

  /* Bias: '<S4>/Bias1' */
  rtb_Bias1 = rtb_Saturation_i + Ctrl_P.Bias1_Bias;

  /* MATLAB Function: '<S4>/MATLAB Function' incorporates:
   *  Gain: '<S4>/Invert'
   *  Inport: '<Root>/RPY'
   *  MATLAB Function: '<S4>/Embedded MATLAB Function1'
   *  Trigonometry: '<S4>/Trigonometric Function1'
   */
  /* MATLAB Function 'Ctrl/Angleconverter/Embedded MATLAB Function1': '<S34>:1' */
  /* '<S34>:1:3' */
  /* '<S34>:1:4' */
  /* '<S34>:1:5' */
  /* MATLAB Function 'Ctrl/Angleconverter/MATLAB Function': '<S35>:1' */
  /* '<S35>:1:3' */
  rtb_y = (real32_T)atan2((rtb_Bias2 * (real32_T)sin(Ctrl_U.RPY[0]) * (real32_T)
    sin(Ctrl_U.RPY[1]) + rtb_Bias * (real32_T)cos(Ctrl_U.RPY[0])) - rtb_Bias1 *
                          (real32_T)sin(Ctrl_U.RPY[0]) * (real32_T)cos
    (Ctrl_U.RPY[1]), rtb_Bias2 * (real32_T)cos(Ctrl_U.RPY[1]) + rtb_Bias1 *
    (real32_T)sin(Ctrl_U.RPY[1])) * Ctrl_P.Invert_Gain / 6.28318548F;
  rtb_y = (rtb_y - (real32_T)floor(rtb_y)) * 6.28318548F;

  /* Chart: '<S1>/Chart' incorporates:
   *  Inport: '<Root>/AckErrr'
   *  Inport: '<Root>/Mode'
   */
  /* Gateway: Ctrl/Chart */
  /* During: Ctrl/Chart */
  if ((int16_T)Ctrl_DWork.is_active_c1_Ctrl == 0) {
    /* Entry: Ctrl/Chart */
    Ctrl_DWork.is_active_c1_Ctrl = 1U;

    /* Entry Internal: Ctrl/Chart */
    Ctrl_DWork.is_active_SystemLogic = 1U;

    /* Entry Internal 'SystemLogic': '<S6>:12' */
    /* Transition: '<S6>:86' */
    Ctrl_DWork.is_SystemLogic = Ctrl_IN_Online;

    /* Entry Internal 'Online': '<S6>:2' */
    /* Transition: '<S6>:16' */
    if ((int16_T)Ctrl_DWork.is_Online != (int16_T)Ctrl_IN_Off) {
      Ctrl_DWork.is_Online = Ctrl_IN_Off;

      /* Entry 'Off': '<S6>:14' */
      Ctrl_B.AMode = 0UL;
    }
  } else {
    if ((int16_T)Ctrl_DWork.is_active_SystemLogic != 0) {
      /* During 'SystemLogic': '<S6>:12' */
      switch (Ctrl_DWork.is_SystemLogic) {
       case Ctrl_IN_Failed:
        /* During 'Failed': '<S6>:3' */
        if (Ctrl_U.AckErrr) {
          /* Transition: '<S6>:11' */
          Ctrl_B.Failed = FALSE;
          Ctrl_DWork.is_SystemLogic = Ctrl_IN_Online;

          /* Entry Internal 'Online': '<S6>:2' */
          /* Transition: '<S6>:16' */
          if ((int16_T)Ctrl_DWork.is_Online != (int16_T)Ctrl_IN_Off) {
            Ctrl_DWork.is_Online = Ctrl_IN_Off;

            /* Entry 'Off': '<S6>:14' */
            Ctrl_B.AMode = 0UL;
          }
        }
        break;

       case Ctrl_IN_Online:
        /* During 'Online': '<S6>:2' */
        Ctrl_SetOutputs(Ctrl_B.AMode);
        if ((Ctrl_U.Mode == 0UL) && (!((int16_T)Ctrl_DWork.is_Online == (int16_T)
              Ctrl_IN_Off))) {
          /* Transition: '<S6>:15' */
          /* Exit Internal 'Online': '<S6>:2' */
          Ctrl_DWork.is_Online = Ctrl_IN_NO_ACTIVE_CHILD;
          if ((int16_T)Ctrl_DWork.is_Online != (int16_T)Ctrl_IN_Off) {
            Ctrl_DWork.is_Online = Ctrl_IN_Off;

            /* Entry 'Off': '<S6>:14' */
            Ctrl_B.AMode = 0UL;
          }
        } else {
          switch (Ctrl_DWork.is_Online) {
           case Ctrl_IN_AltMode:
            break;

           case Ctrl_IN_AutoMode:
            break;

           case Ctrl_IN_Off:
            /* During 'Off': '<S6>:14' */
            if (Ctrl_U.Mode == 1UL) {
              /* Transition: '<S6>:17' */
              Ctrl_DWork.is_Online = Ctrl_IN_RateMode;

              /* Entry 'RateMode': '<S6>:13' */
              Ctrl_B.AMode = 1UL;
            } else if (Ctrl_U.Mode == 2UL) {
              /* Transition: '<S6>:89' */
              Ctrl_DWork.is_Online = Ctrl_IN_RollPitchMode;

              /* Entry 'RollPitchMode': '<S6>:87' */
              Ctrl_B.AMode = 2UL;
            } else if (Ctrl_U.Mode == 3UL) {
              /* Transition: '<S6>:90' */
              Ctrl_DWork.is_Online = Ctrl_IN_AltMode;

              /* Entry 'AltMode': '<S6>:88' */
              Ctrl_B.AMode = 3UL;
            } else {
              if (Ctrl_U.Mode == 4UL) {
                /* Transition: '<S6>:133' */
                Ctrl_DWork.is_Online = Ctrl_IN_AutoMode;

                /* Entry 'AutoMode': '<S6>:132' */
                Ctrl_B.AMode = 4UL;
              }
            }
            break;

           case Ctrl_IN_RateMode:
            break;

           case Ctrl_IN_RollPitchMode:
            break;

           default:
            Ctrl_DWork.is_Online = Ctrl_IN_NO_ACTIVE_CHILD;
            break;
          }
        }
        break;

       default:
        Ctrl_DWork.is_SystemLogic = Ctrl_IN_NO_ACTIVE_CHILD;
        break;
      }
    }
  }

  /* End of Chart: '<S1>/Chart' */

  /* Outputs for Enabled SubSystem: '<S1>/AltCtrl' incorporates:
   *  EnablePort: '<S3>/Enable'
   */
  if (Ctrl_B.CtrlAlt) {
    if (!Ctrl_DWork.AltCtrl_MODE) {
      /* InitializeConditions for DiscreteIntegrator: '<S29>/Filter' */
      Ctrl_DWork.Filter_DSTATE_di = Ctrl_P.Filter_IC;

      /* InitializeConditions for DiscreteIntegrator: '<S28>/Filter' */
      Ctrl_DWork.Filter_DSTATE_k = Ctrl_P.Filter_IC_k;

      /* InitializeConditions for DiscreteIntegrator: '<S26>/Filter' */
      Ctrl_DWork.Filter_DSTATE_c3b = Ctrl_P.Filter_IC_d;

      /* InitializeConditions for DiscreteIntegrator: '<S25>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_b = Ctrl_P.Integrator_IC;

      /* InitializeConditions for DiscreteIntegrator: '<S25>/Filter' */
      Ctrl_DWork.Filter_DSTATE_g = Ctrl_P.Filter_IC_i;

      /* InitializeConditions for DiscreteIntegrator: '<S31>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_l = Ctrl_P.Integrator_IC_c;

      /* InitializeConditions for DiscreteIntegrator: '<S23>/Filter' */
      Ctrl_DWork.Filter_DSTATE_m = Ctrl_P.Filter_IC_dg;

      /* InitializeConditions for DiscreteIntegrator: '<S22>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_n = Ctrl_P.Integrator_IC_g;

      /* InitializeConditions for DiscreteIntegrator: '<S22>/Filter' */
      Ctrl_DWork.Filter_DSTATE_fe = Ctrl_P.Filter_IC_ko;
      Ctrl_DWork.AltCtrl_MODE = TRUE;
    }

    /* Lookup_n-D: '<S3>/1-D Lookup Table' incorporates:
     *  Inport: '<Root>/Throttle'
     */
    Kk_idx_0 = look1_iflf_binlxpw(Ctrl_U.Throttle, Ctrl_P.DLookupTable_bp01Data,
      Ctrl_P.DLookupTable_tableData, 3UL);

    /* Sum: '<S16>/Sum2' incorporates:
     *  Gain: '<S16>/Ve Scaler'
     *  Inport: '<Root>/FlatVe'
     *  Inport: '<Root>/Pitch'
     */
    rtb_Add6_g = Ctrl_P.VeScaler_Gain * Ctrl_U.Pitch - Ctrl_U.FlatVe[0];

    /* Gain: '<S29>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S29>/Filter'
     *  Gain: '<S29>/Derivative Gain'
     *  Sum: '<S29>/SumD'
     */
    rtb_FilterCoefficient_p = (Ctrl_P.DerivativeGain_Gain * rtb_Add6_g -
      Ctrl_DWork.Filter_DSTATE_di) * Ctrl_P.FilterCoefficient_Gain;

    /* Sum: '<S29>/Sum' incorporates:
     *  Gain: '<S29>/Proportional Gain'
     */
    rtb_Add6_g = Ctrl_P.ProportionalGain_Gain * rtb_Add6_g +
      rtb_FilterCoefficient_p;

    /* Saturate: '<S29>/Saturation' */
    if (rtb_Add6_g >= Ctrl_P.Saturation_UpperSat) {
      rtb_Add6_g = Ctrl_P.Saturation_UpperSat;
    } else {
      if (rtb_Add6_g <= Ctrl_P.Saturation_LowerSat) {
        rtb_Add6_g = Ctrl_P.Saturation_LowerSat;
      }
    }

    /* End of Saturate: '<S29>/Saturation' */

    /* Trigonometry: '<S16>/Trigonometric Function' */
    rtb_Bias1 = (real32_T)sin(rtb_y);
    rtb_Bias2 = (real32_T)cos(rtb_y);

    /* Sum: '<S16>/Sum1' incorporates:
     *  Gain: '<S16>/Ve Scaler1'
     *  Inport: '<Root>/FlatVe'
     *  Inport: '<Root>/Roll'
     */
    rtb_IntegralGain_e = Ctrl_P.VeScaler1_Gain * Ctrl_U.Roll - Ctrl_U.FlatVe[1];

    /* Gain: '<S28>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S28>/Filter'
     *  Gain: '<S28>/Derivative Gain'
     *  Sum: '<S28>/SumD'
     */
    rtb_FilterCoefficient_e4 = (Ctrl_P.DerivativeGain_Gain_i *
      rtb_IntegralGain_e - Ctrl_DWork.Filter_DSTATE_k) *
      Ctrl_P.FilterCoefficient_Gain_i;

    /* Sum: '<S28>/Sum' incorporates:
     *  Gain: '<S28>/Proportional Gain'
     */
    rtb_IntegralGain_e = Ctrl_P.ProportionalGain_Gain_a * rtb_IntegralGain_e +
      rtb_FilterCoefficient_e4;

    /* Saturate: '<S28>/Saturation' */
    if (rtb_IntegralGain_e >= Ctrl_P.Saturation_UpperSat_n) {
      rtb_IntegralGain_e = Ctrl_P.Saturation_UpperSat_n;
    } else {
      if (rtb_IntegralGain_e <= Ctrl_P.Saturation_LowerSat_m) {
        rtb_IntegralGain_e = Ctrl_P.Saturation_LowerSat_m;
      }
    }

    /* End of Saturate: '<S28>/Saturation' */

    /* Sum: '<S15>/Sum1' incorporates:
     *  Gain: '<S15>/Scale roll2'
     *  Inport: '<Root>/RPY'
     *  Product: '<S16>/Product2'
     *  Product: '<S16>/Product3'
     *  Sum: '<S16>/Add1'
     *  Trigonometry: '<S16>/Trigonometric Function'
     */
    rtb_IntegralGain_oq = (rtb_Bias2 * rtb_IntegralGain_e - rtb_Add6_g *
      rtb_Bias1) * Ctrl_P.Scaleroll2_Gain - Ctrl_U.RPY[0];

    /* Gain: '<S26>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S26>/Filter'
     *  Gain: '<S26>/Derivative Gain'
     *  Sum: '<S26>/SumD'
     */
    rtb_FilterCoefficient_at = (Ctrl_P.DerivativeGain_Gain_h *
      rtb_IntegralGain_oq - Ctrl_DWork.Filter_DSTATE_c3b) *
      Ctrl_P.FilterCoefficient_Gain_is;

    /* Sum: '<S15>/Sum' incorporates:
     *  Gain: '<S26>/Proportional Gain'
     *  Inport: '<Root>/omega'
     *  Sum: '<S26>/Sum'
     */
    rtb_IntegralGain_oq = (Ctrl_P.ProportionalGain_Gain_c * rtb_IntegralGain_oq
      + rtb_FilterCoefficient_at) - Ctrl_U.omega[0];

    /* Gain: '<S25>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S25>/Filter'
     *  Gain: '<S25>/Derivative Gain'
     *  Sum: '<S25>/SumD'
     */
    rtb_FilterCoefficient_ox = (Ctrl_P.DerivativeGain_Gain_e *
      rtb_IntegralGain_oq - Ctrl_DWork.Filter_DSTATE_g) *
      Ctrl_P.FilterCoefficient_Gain_e;

    /* Sum: '<S25>/Sum' incorporates:
     *  DiscreteIntegrator: '<S25>/Integrator'
     *  Gain: '<S25>/Proportional Gain'
     */
    rtb_Sum_am = (Ctrl_P.ProportionalGain_Gain_a5 * rtb_IntegralGain_oq +
                  Ctrl_DWork.Integrator_DSTATE_b) + rtb_FilterCoefficient_ox;

    /* Saturate: '<S25>/Saturation' */
    if (rtb_Sum_am >= Ctrl_P.Saturation_UpperSat_g) {
      rtb_Saturation_a = Ctrl_P.Saturation_UpperSat_g;
    } else if (rtb_Sum_am <= Ctrl_P.Saturation_LowerSat_mp) {
      rtb_Saturation_a = Ctrl_P.Saturation_LowerSat_mp;
    } else {
      rtb_Saturation_a = rtb_Sum_am;
    }

    /* End of Saturate: '<S25>/Saturation' */

    /* Gain: '<S15>/Scale roll' */
    rtb_Add4_e = Ctrl_P.Scaleroll_Gain * rtb_Saturation_a;

    /* Sum: '<S17>/Sum1' incorporates:
     *  Gain: '<S17>/Scale roll2'
     *  Inport: '<Root>/Yaw'
     */
    rtb_Sum1_h = Ctrl_P.Scaleroll2_Gain_i * Ctrl_U.Yaw - rtb_y;

    /* MATLAB Function: '<S17>/Correct Yaw' */
    Ctrl_CorrectYaw(rtb_Sum1_h, &Ctrl_B.sf_CorrectYaw);

    /* Gain: '<S32>/Proportional Gain' */
    Kk_idx = Ctrl_P.ProportionalGain_Gain_e * Ctrl_B.sf_CorrectYaw.y;

    /* Saturate: '<S32>/Saturation' */
    if (Kk_idx >= Ctrl_P.Saturation_UpperSat_i) {
      Kk_idx = Ctrl_P.Saturation_UpperSat_i;
    } else {
      if (Kk_idx <= Ctrl_P.Saturation_LowerSat_n) {
        Kk_idx = Ctrl_P.Saturation_LowerSat_n;
      }
    }

    /* Sum: '<S17>/Sum' incorporates:
     *  Inport: '<Root>/omega'
     *  Saturate: '<S32>/Saturation'
     */
    rtb_IntegralGain_p0 = Kk_idx - Ctrl_U.omega[2];

    /* Sum: '<S31>/Sum' incorporates:
     *  DiscreteIntegrator: '<S31>/Integrator'
     *  Gain: '<S31>/Proportional Gain'
     */
    rtb_Sum_p = Ctrl_P.ProportionalGain_Gain_m * rtb_IntegralGain_p0 +
      Ctrl_DWork.Integrator_DSTATE_l;

    /* Saturate: '<S31>/Saturation' */
    if (rtb_Sum_p >= Ctrl_P.Saturation_UpperSat_p) {
      rtb_Saturation_kd = Ctrl_P.Saturation_UpperSat_p;
    } else if (rtb_Sum_p <= Ctrl_P.Saturation_LowerSat_nb) {
      rtb_Saturation_kd = Ctrl_P.Saturation_LowerSat_nb;
    } else {
      rtb_Saturation_kd = rtb_Sum_p;
    }

    /* End of Saturate: '<S31>/Saturation' */

    /* Gain: '<S17>/Scale yaw' */
    rtb_Scaleyaw_o = Ctrl_P.Scaleyaw_Gain * rtb_Saturation_kd;

    /* Sum: '<S3>/Add3' */
    rtb_Add3_f = (Kk_idx_0 - rtb_Add4_e) + rtb_Scaleyaw_o;

    /* Sum: '<S3>/Add4' */
    rtb_Add4_e = (rtb_Add4_e + Kk_idx_0) + rtb_Scaleyaw_o;

    /* Sum: '<S14>/Sum1' incorporates:
     *  Gain: '<S14>/Scale pitch1'
     *  Gain: '<S16>/Invert Pitch ref1'
     *  Inport: '<Root>/RPY'
     *  Product: '<S16>/Product'
     *  Product: '<S16>/Product1'
     *  Sum: '<S16>/Add'
     *  Trigonometry: '<S16>/Trigonometric Function'
     */
    rtb_IntegralGain_e = (rtb_Add6_g * rtb_Bias2 + rtb_Bias1 *
                          rtb_IntegralGain_e) * Ctrl_P.InvertPitchref1_Gain *
      Ctrl_P.Scalepitch1_Gain - Ctrl_U.RPY[1];

    /* Gain: '<S23>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S23>/Filter'
     *  Gain: '<S23>/Derivative Gain'
     *  Sum: '<S23>/SumD'
     */
    rtb_Bias1 = (Ctrl_P.DerivativeGain_Gain_g * rtb_IntegralGain_e -
                 Ctrl_DWork.Filter_DSTATE_m) * Ctrl_P.FilterCoefficient_Gain_j;

    /* Sum: '<S14>/Sum' incorporates:
     *  Gain: '<S23>/Proportional Gain'
     *  Inport: '<Root>/omega'
     *  Sum: '<S23>/Sum'
     */
    rtb_IntegralGain_e = (Ctrl_P.ProportionalGain_Gain_o * rtb_IntegralGain_e +
                          rtb_Bias1) - Ctrl_U.omega[1];

    /* Gain: '<S22>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S22>/Filter'
     *  Gain: '<S22>/Derivative Gain'
     *  Sum: '<S22>/SumD'
     */
    rtb_Bias2 = (Ctrl_P.DerivativeGain_Gain_d * rtb_IntegralGain_e -
                 Ctrl_DWork.Filter_DSTATE_fe) * Ctrl_P.FilterCoefficient_Gain_d;

    /* Sum: '<S22>/Sum' incorporates:
     *  DiscreteIntegrator: '<S22>/Integrator'
     *  Gain: '<S22>/Proportional Gain'
     */
    rtb_Bias = (Ctrl_P.ProportionalGain_Gain_h * rtb_IntegralGain_e +
                Ctrl_DWork.Integrator_DSTATE_n) + rtb_Bias2;

    /* Saturate: '<S22>/Saturation' */
    if (rtb_Bias >= Ctrl_P.Saturation_UpperSat_gy) {
      rtb_Saturation_i = Ctrl_P.Saturation_UpperSat_gy;
    } else if (rtb_Bias <= Ctrl_P.Saturation_LowerSat_f) {
      rtb_Saturation_i = Ctrl_P.Saturation_LowerSat_f;
    } else {
      rtb_Saturation_i = rtb_Bias;
    }

    /* End of Saturate: '<S22>/Saturation' */

    /* Gain: '<S14>/Scale pitch' */
    rtb_Add6_g = Ctrl_P.Scalepitch_Gain * rtb_Saturation_i;

    /* Sum: '<S3>/Add5' */
    rtb_Add5_m = (Kk_idx_0 - rtb_Add6_g) - rtb_Scaleyaw_o;

    /* Sum: '<S3>/Add6' */
    rtb_Add6_g = (rtb_Add6_g + Kk_idx_0) - rtb_Scaleyaw_o;

    /* Saturate: '<S3>/Limit1' */
    if (rtb_Add5_m >= Ctrl_P.Limit1_UpperSat) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_UpperSat;
    } else if (rtb_Add5_m <= Ctrl_P.Limit1_LowerSat) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_LowerSat;
    } else {
      Ctrl_B.PWM2 = rtb_Add5_m;
    }

    /* End of Saturate: '<S3>/Limit1' */

    /* Saturate: '<S3>/Limit2' */
    if (rtb_Add4_e >= Ctrl_P.Limit2_UpperSat) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_UpperSat;
    } else if (rtb_Add4_e <= Ctrl_P.Limit2_LowerSat) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_LowerSat;
    } else {
      Ctrl_B.PWM3 = rtb_Add4_e;
    }

    /* End of Saturate: '<S3>/Limit2' */

    /* Saturate: '<S3>/Limit3' */
    if (rtb_Add3_f >= Ctrl_P.Limit3_UpperSat) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_UpperSat;
    } else if (rtb_Add3_f <= Ctrl_P.Limit3_LowerSat) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_LowerSat;
    } else {
      Ctrl_B.PWM1 = rtb_Add3_f;
    }

    /* End of Saturate: '<S3>/Limit3' */

    /* Saturate: '<S3>/Limit4' */
    if (rtb_Add6_g >= Ctrl_P.Limit4_UpperSat) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_UpperSat;
    } else if (rtb_Add6_g <= Ctrl_P.Limit4_LowerSat) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_LowerSat;
    } else {
      Ctrl_B.PWM4 = rtb_Add6_g;
    }

    /* End of Saturate: '<S3>/Limit4' */

    /* Gain: '<S22>/Integral Gain' */
    rtb_IntegralGain_e *= Ctrl_P.IntegralGain_Gain;

    /* Gain: '<S25>/Integral Gain' */
    rtb_IntegralGain_oq *= Ctrl_P.IntegralGain_Gain_i;

    /* Gain: '<S31>/Integral Gain' */
    rtb_IntegralGain_p0 *= Ctrl_P.IntegralGain_Gain_m;

    /* Update for DiscreteIntegrator: '<S29>/Filter' */
    Ctrl_DWork.Filter_DSTATE_di += Ctrl_P.Filter_gainval *
      rtb_FilterCoefficient_p;

    /* Update for DiscreteIntegrator: '<S28>/Filter' */
    Ctrl_DWork.Filter_DSTATE_k += Ctrl_P.Filter_gainval_n *
      rtb_FilterCoefficient_e4;

    /* Update for DiscreteIntegrator: '<S26>/Filter' */
    Ctrl_DWork.Filter_DSTATE_c3b += Ctrl_P.Filter_gainval_e *
      rtb_FilterCoefficient_at;

    /* Signum: '<S27>/SignPreSat' */
    if (rtb_Sum_am < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Sum_am > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Sum_am;
    }

    /* Signum: '<S27>/SignPreIntegrator' */
    if (rtb_IntegralGain_oq < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_IntegralGain_oq > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_IntegralGain_oq;
    }

    /* Switch: '<S25>/Switch' incorporates:
     *  Constant: '<S25>/Constant'
     *  Logic: '<S27>/AND'
     *  RelationalOperator: '<S27>/Equal'
     *  RelationalOperator: '<S27>/NotEqual'
     *  Signum: '<S27>/SignPreIntegrator'
     *  Signum: '<S27>/SignPreSat'
     */
    if ((rtb_Sum_am != rtb_Saturation_a) && (Kk_idx == Kk_idx_0)) {
      rtb_IntegralGain_oq = Ctrl_P.Constant_Value_e;
    }

    /* End of Switch: '<S25>/Switch' */

    /* Update for DiscreteIntegrator: '<S25>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_b += Ctrl_P.Integrator_gainval *
      rtb_IntegralGain_oq;

    /* Update for DiscreteIntegrator: '<S25>/Filter' */
    Ctrl_DWork.Filter_DSTATE_g += Ctrl_P.Filter_gainval_h *
      rtb_FilterCoefficient_ox;

    /* Signum: '<S33>/SignPreSat' */
    if (rtb_Sum_p < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Sum_p > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Sum_p;
    }

    /* Signum: '<S33>/SignPreIntegrator' */
    if (rtb_IntegralGain_p0 < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_IntegralGain_p0 > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_IntegralGain_p0;
    }

    /* Switch: '<S31>/Switch' incorporates:
     *  Constant: '<S31>/Constant'
     *  Logic: '<S33>/AND'
     *  RelationalOperator: '<S33>/Equal'
     *  RelationalOperator: '<S33>/NotEqual'
     *  Signum: '<S33>/SignPreIntegrator'
     *  Signum: '<S33>/SignPreSat'
     */
    if ((rtb_Sum_p != rtb_Saturation_kd) && (Kk_idx == Kk_idx_0)) {
      rtb_IntegralGain_p0 = Ctrl_P.Constant_Value_g;
    }

    /* End of Switch: '<S31>/Switch' */

    /* Update for DiscreteIntegrator: '<S31>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_l += Ctrl_P.Integrator_gainval_i *
      rtb_IntegralGain_p0;

    /* Update for DiscreteIntegrator: '<S23>/Filter' */
    Ctrl_DWork.Filter_DSTATE_m += Ctrl_P.Filter_gainval_i * rtb_Bias1;

    /* Signum: '<S24>/SignPreSat' */
    if (rtb_Bias < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_Bias > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_Bias;
    }

    /* Signum: '<S24>/SignPreIntegrator' */
    if (rtb_IntegralGain_e < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_IntegralGain_e > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_IntegralGain_e;
    }

    /* Switch: '<S22>/Switch' incorporates:
     *  Constant: '<S22>/Constant'
     *  Logic: '<S24>/AND'
     *  RelationalOperator: '<S24>/Equal'
     *  RelationalOperator: '<S24>/NotEqual'
     *  Signum: '<S24>/SignPreIntegrator'
     *  Signum: '<S24>/SignPreSat'
     */
    if ((rtb_Bias != rtb_Saturation_i) && (Kk_idx_0 == Kk_idx)) {
      rtb_IntegralGain_e = Ctrl_P.Constant_Value;
    }

    /* End of Switch: '<S22>/Switch' */

    /* Update for DiscreteIntegrator: '<S22>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_n += Ctrl_P.Integrator_gainval_n *
      rtb_IntegralGain_e;

    /* Update for DiscreteIntegrator: '<S22>/Filter' */
    Ctrl_DWork.Filter_DSTATE_fe += Ctrl_P.Filter_gainval_j * rtb_Bias2;
  } else {
    if (Ctrl_DWork.AltCtrl_MODE) {
      Ctrl_DWork.AltCtrl_MODE = FALSE;
    }
  }

  /* End of Outputs for SubSystem: '<S1>/AltCtrl' */

  /* Outputs for Enabled SubSystem: '<S1>/AutoCtrl' incorporates:
   *  EnablePort: '<S5>/Enable'
   */
  if (Ctrl_B.CtrlAuto) {
    if (!Ctrl_DWork.AutoCtrl_MODE) {
      /* InitializeConditions for DiscreteIntegrator: '<S50>/Filter' */
      Ctrl_DWork.Filter_DSTATE_ed = Ctrl_P.Filter_IC_j;

      /* InitializeConditions for DiscreteIntegrator: '<S55>/Filter' */
      Ctrl_DWork.Filter_DSTATE_dt = Ctrl_P.Filter_IC_n;

      /* InitializeConditions for DiscreteIntegrator: '<S49>/Filter' */
      Ctrl_DWork.Filter_DSTATE_c3 = Ctrl_P.Filter_IC_a;

      /* InitializeConditions for DiscreteIntegrator: '<S54>/Filter' */
      Ctrl_DWork.Filter_DSTATE_al = Ctrl_P.Filter_IC_c;

      /* InitializeConditions for DiscreteIntegrator: '<S52>/Filter' */
      Ctrl_DWork.Filter_DSTATE_cm = Ctrl_P.Filter_IC_o;

      /* InitializeConditions for DiscreteIntegrator: '<S51>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_k = Ctrl_P.Integrator_IC_m;

      /* InitializeConditions for DiscreteIntegrator: '<S51>/Filter' */
      Ctrl_DWork.Filter_DSTATE_cj = Ctrl_P.Filter_IC_of;

      /* InitializeConditions for DiscreteIntegrator: '<S57>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_e = Ctrl_P.Integrator_IC_k;

      /* InitializeConditions for DiscreteIntegrator: '<S47>/Filter' */
      Ctrl_DWork.Filter_DSTATE_ds = Ctrl_P.Filter_IC_f;

      /* InitializeConditions for DiscreteIntegrator: '<S46>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_kk = Ctrl_P.Integrator_IC_o;

      /* InitializeConditions for DiscreteIntegrator: '<S46>/Filter' */
      Ctrl_DWork.Filter_DSTATE_n = Ctrl_P.Filter_IC_cm;
      Ctrl_DWork.AutoCtrl_MODE = TRUE;
    }

    /* Lookup_n-D: '<S5>/1-D Lookup Table' incorporates:
     *  Inport: '<Root>/Throttle'
     */
    rtb_DLookupTable_l = look1_iflf_binlxpw(Ctrl_U.Throttle,
      Ctrl_P.DLookupTable_bp01Data_l, Ctrl_P.DLookupTable_tableData_d, 3UL);

    /* Sum: '<S38>/Sum2' incorporates:
     *  Inport: '<Root>/FlatXe'
     *  Inport: '<Root>/XeXRef'
     */
    rtb_Saturation_i = Ctrl_U.XeXRef - Ctrl_U.FlatXe[0];

    /* Gain: '<S50>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S50>/Filter'
     *  Gain: '<S50>/Derivative Gain'
     *  Sum: '<S50>/SumD'
     */
    rtb_Add5_m = (Ctrl_P.DerivativeGain_Gain_j * rtb_Saturation_i -
                  Ctrl_DWork.Filter_DSTATE_ed) *
      Ctrl_P.FilterCoefficient_Gain_db;

    /* Sum: '<S50>/Sum' incorporates:
     *  Gain: '<S50>/Proportional Gain'
     */
    Kk_idx = Ctrl_P.ProportionalGain_Gain_ot * rtb_Saturation_i + rtb_Add5_m;

    /* Saturate: '<S50>/Saturation' */
    if (Kk_idx >= Ctrl_P.Saturation_UpperSat_b) {
      Kk_idx = Ctrl_P.Saturation_UpperSat_b;
    } else {
      if (Kk_idx <= Ctrl_P.Saturation_LowerSat_b) {
        Kk_idx = Ctrl_P.Saturation_LowerSat_b;
      }
    }

    /* Sum: '<S40>/Sum2' incorporates:
     *  Inport: '<Root>/FlatVe'
     *  Saturate: '<S50>/Saturation'
     */
    rtb_Saturation_i = Kk_idx - Ctrl_U.FlatVe[0];

    /* Gain: '<S55>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S55>/Filter'
     *  Gain: '<S55>/Derivative Gain'
     *  Sum: '<S55>/SumD'
     */
    rtb_Add6_g = (Ctrl_P.DerivativeGain_Gain_n * rtb_Saturation_i -
                  Ctrl_DWork.Filter_DSTATE_dt) * Ctrl_P.FilterCoefficient_Gain_p;

    /* Sum: '<S55>/Sum' incorporates:
     *  Gain: '<S55>/Proportional Gain'
     */
    rtb_Saturation_i = Ctrl_P.ProportionalGain_Gain_oo * rtb_Saturation_i +
      rtb_Add6_g;

    /* Saturate: '<S55>/Saturation' */
    if (rtb_Saturation_i >= Ctrl_P.Saturation_UpperSat_l) {
      rtb_Saturation_i = Ctrl_P.Saturation_UpperSat_l;
    } else {
      if (rtb_Saturation_i <= Ctrl_P.Saturation_LowerSat_nl) {
        rtb_Saturation_i = Ctrl_P.Saturation_LowerSat_nl;
      }
    }

    /* End of Saturate: '<S55>/Saturation' */

    /* Trigonometry: '<S40>/Trigonometric Function' */
    rtb_Bias1 = (real32_T)sin(rtb_y);
    rtb_Bias2 = (real32_T)cos(rtb_y);

    /* Sum: '<S38>/Sum1' incorporates:
     *  Inport: '<Root>/FlatXe'
     *  Inport: '<Root>/XeYRef'
     */
    rtb_FilterCoefficient_p = Ctrl_U.XeYRef - Ctrl_U.FlatXe[1];

    /* Gain: '<S49>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S49>/Filter'
     *  Gain: '<S49>/Derivative Gain'
     *  Sum: '<S49>/SumD'
     */
    rtb_IntegralGain_e = (Ctrl_P.DerivativeGain_Gain_hy *
                          rtb_FilterCoefficient_p - Ctrl_DWork.Filter_DSTATE_c3)
      * Ctrl_P.FilterCoefficient_Gain_b;

    /* Sum: '<S49>/Sum' incorporates:
     *  Gain: '<S49>/Proportional Gain'
     */
    Kk_idx = Ctrl_P.ProportionalGain_Gain_ee * rtb_FilterCoefficient_p +
      rtb_IntegralGain_e;

    /* Saturate: '<S49>/Saturation' */
    if (Kk_idx >= Ctrl_P.Saturation_UpperSat_lj) {
      Kk_idx = Ctrl_P.Saturation_UpperSat_lj;
    } else {
      if (Kk_idx <= Ctrl_P.Saturation_LowerSat_na) {
        Kk_idx = Ctrl_P.Saturation_LowerSat_na;
      }
    }

    /* Sum: '<S40>/Sum1' incorporates:
     *  Inport: '<Root>/FlatVe'
     *  Saturate: '<S49>/Saturation'
     */
    rtb_FilterCoefficient_p = Kk_idx - Ctrl_U.FlatVe[1];

    /* Gain: '<S54>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S54>/Filter'
     *  Gain: '<S54>/Derivative Gain'
     *  Sum: '<S54>/SumD'
     */
    rtb_FilterCoefficient_e4 = (Ctrl_P.DerivativeGain_Gain_nj *
      rtb_FilterCoefficient_p - Ctrl_DWork.Filter_DSTATE_al) *
      Ctrl_P.FilterCoefficient_Gain_iw;

    /* Sum: '<S54>/Sum' incorporates:
     *  Gain: '<S54>/Proportional Gain'
     */
    rtb_FilterCoefficient_p = Ctrl_P.ProportionalGain_Gain_n *
      rtb_FilterCoefficient_p + rtb_FilterCoefficient_e4;

    /* Saturate: '<S54>/Saturation' */
    if (rtb_FilterCoefficient_p >= Ctrl_P.Saturation_UpperSat_a) {
      rtb_FilterCoefficient_p = Ctrl_P.Saturation_UpperSat_a;
    } else {
      if (rtb_FilterCoefficient_p <= Ctrl_P.Saturation_LowerSat_d) {
        rtb_FilterCoefficient_p = Ctrl_P.Saturation_LowerSat_d;
      }
    }

    /* End of Saturate: '<S54>/Saturation' */

    /* Sum: '<S39>/Sum1' incorporates:
     *  Gain: '<S39>/Scale roll2'
     *  Inport: '<Root>/RPY'
     *  Product: '<S40>/Product2'
     *  Product: '<S40>/Product3'
     *  Sum: '<S40>/Add1'
     *  Trigonometry: '<S40>/Trigonometric Function'
     */
    rtb_IntegralGain_oq = (rtb_Bias2 * rtb_FilterCoefficient_p -
      rtb_Saturation_i * rtb_Bias1) * Ctrl_P.Scaleroll2_Gain_l - Ctrl_U.RPY[0];

    /* Gain: '<S52>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S52>/Filter'
     *  Gain: '<S52>/Derivative Gain'
     *  Sum: '<S52>/SumD'
     */
    rtb_FilterCoefficient_at = (Ctrl_P.DerivativeGain_Gain_f *
      rtb_IntegralGain_oq - Ctrl_DWork.Filter_DSTATE_cm) *
      Ctrl_P.FilterCoefficient_Gain_g;

    /* Sum: '<S39>/Sum' incorporates:
     *  Gain: '<S52>/Proportional Gain'
     *  Inport: '<Root>/omega'
     *  Sum: '<S52>/Sum'
     */
    rtb_IntegralGain_oq = (Ctrl_P.ProportionalGain_Gain_hr * rtb_IntegralGain_oq
      + rtb_FilterCoefficient_at) - Ctrl_U.omega[0];

    /* Gain: '<S51>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S51>/Filter'
     *  Gain: '<S51>/Derivative Gain'
     *  Sum: '<S51>/SumD'
     */
    rtb_FilterCoefficient_ox = (Ctrl_P.DerivativeGain_Gain_o *
      rtb_IntegralGain_oq - Ctrl_DWork.Filter_DSTATE_cj) *
      Ctrl_P.FilterCoefficient_Gain_l;

    /* Sum: '<S51>/Sum' incorporates:
     *  DiscreteIntegrator: '<S51>/Integrator'
     *  Gain: '<S51>/Proportional Gain'
     */
    rtb_Sum_am = (Ctrl_P.ProportionalGain_Gain_b * rtb_IntegralGain_oq +
                  Ctrl_DWork.Integrator_DSTATE_k) + rtb_FilterCoefficient_ox;

    /* Saturate: '<S51>/Saturation' */
    if (rtb_Sum_am >= Ctrl_P.Saturation_UpperSat_l0) {
      rtb_Saturation_a = Ctrl_P.Saturation_UpperSat_l0;
    } else if (rtb_Sum_am <= Ctrl_P.Saturation_LowerSat_k) {
      rtb_Saturation_a = Ctrl_P.Saturation_LowerSat_k;
    } else {
      rtb_Saturation_a = rtb_Sum_am;
    }

    /* End of Saturate: '<S51>/Saturation' */

    /* Gain: '<S39>/Scale roll' */
    rtb_Add4_e = Ctrl_P.Scaleroll_Gain_j * rtb_Saturation_a;

    /* Sum: '<S41>/Sum1' incorporates:
     *  Gain: '<S41>/Scale roll2'
     *  Inport: '<Root>/Yaw'
     */
    rtb_Sum1 = Ctrl_P.Scaleroll2_Gain_n * Ctrl_U.Yaw - rtb_y;

    /* MATLAB Function: '<S41>/Correct Yaw' */
    Ctrl_CorrectYaw(rtb_Sum1, &Ctrl_B.sf_CorrectYaw_e);

    /* Gain: '<S58>/Proportional Gain' */
    Kk_idx = Ctrl_P.ProportionalGain_Gain_d * Ctrl_B.sf_CorrectYaw_e.y;

    /* Saturate: '<S58>/Saturation' */
    if (Kk_idx >= Ctrl_P.Saturation_UpperSat_f) {
      Kk_idx = Ctrl_P.Saturation_UpperSat_f;
    } else {
      if (Kk_idx <= Ctrl_P.Saturation_LowerSat_p) {
        Kk_idx = Ctrl_P.Saturation_LowerSat_p;
      }
    }

    /* Sum: '<S41>/Sum' incorporates:
     *  Inport: '<Root>/omega'
     *  Saturate: '<S58>/Saturation'
     */
    rtb_IntegralGain_p0 = Kk_idx - Ctrl_U.omega[2];

    /* Sum: '<S57>/Sum' incorporates:
     *  DiscreteIntegrator: '<S57>/Integrator'
     *  Gain: '<S57>/Proportional Gain'
     */
    rtb_Scaleyaw_o = Ctrl_P.ProportionalGain_Gain_p * rtb_IntegralGain_p0 +
      Ctrl_DWork.Integrator_DSTATE_e;

    /* Saturate: '<S57>/Saturation' */
    if (rtb_Scaleyaw_o >= Ctrl_P.Saturation_UpperSat_m) {
      rtb_Add3_f = Ctrl_P.Saturation_UpperSat_m;
    } else if (rtb_Scaleyaw_o <= Ctrl_P.Saturation_LowerSat_fd) {
      rtb_Add3_f = Ctrl_P.Saturation_LowerSat_fd;
    } else {
      rtb_Add3_f = rtb_Scaleyaw_o;
    }

    /* End of Saturate: '<S57>/Saturation' */

    /* Gain: '<S41>/Scale yaw' */
    Kk_idx_0 = Ctrl_P.Scaleyaw_Gain_i * rtb_Add3_f;

    /* Sum: '<S5>/Add3' */
    Kk_idx = (rtb_DLookupTable_l - rtb_Add4_e) + Kk_idx_0;

    /* Sum: '<S5>/Add4' */
    rtb_Add4_e = (rtb_Add4_e + rtb_DLookupTable_l) + Kk_idx_0;

    /* Sum: '<S37>/Sum1' incorporates:
     *  Gain: '<S37>/Scale pitch1'
     *  Gain: '<S40>/Invert Pitch ref1'
     *  Inport: '<Root>/RPY'
     *  Product: '<S40>/Product'
     *  Product: '<S40>/Product1'
     *  Sum: '<S40>/Add'
     *  Trigonometry: '<S40>/Trigonometric Function'
     */
    rtb_FilterCoefficient_p = (rtb_Saturation_i * rtb_Bias2 + rtb_Bias1 *
      rtb_FilterCoefficient_p) * Ctrl_P.InvertPitchref1_Gain_b *
      Ctrl_P.Scalepitch1_Gain_o - Ctrl_U.RPY[1];

    /* Gain: '<S47>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S47>/Filter'
     *  Gain: '<S47>/Derivative Gain'
     *  Sum: '<S47>/SumD'
     */
    rtb_Bias1 = (Ctrl_P.DerivativeGain_Gain_e0 * rtb_FilterCoefficient_p -
                 Ctrl_DWork.Filter_DSTATE_ds) * Ctrl_P.FilterCoefficient_Gain_h;

    /* Sum: '<S37>/Sum' incorporates:
     *  Gain: '<S47>/Proportional Gain'
     *  Inport: '<Root>/omega'
     *  Sum: '<S47>/Sum'
     */
    rtb_FilterCoefficient_p = (Ctrl_P.ProportionalGain_Gain_f *
      rtb_FilterCoefficient_p + rtb_Bias1) - Ctrl_U.omega[1];

    /* Gain: '<S46>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S46>/Filter'
     *  Gain: '<S46>/Derivative Gain'
     *  Sum: '<S46>/SumD'
     */
    rtb_Bias2 = (Ctrl_P.DerivativeGain_Gain_dl * rtb_FilterCoefficient_p -
                 Ctrl_DWork.Filter_DSTATE_n) * Ctrl_P.FilterCoefficient_Gain_c;

    /* Sum: '<S46>/Sum' incorporates:
     *  DiscreteIntegrator: '<S46>/Integrator'
     *  Gain: '<S46>/Proportional Gain'
     */
    rtb_Bias = (Ctrl_P.ProportionalGain_Gain_or * rtb_FilterCoefficient_p +
                Ctrl_DWork.Integrator_DSTATE_kk) + rtb_Bias2;

    /* Saturate: '<S46>/Saturation' */
    if (rtb_Bias >= Ctrl_P.Saturation_UpperSat_k) {
      rtb_Sum_p = Ctrl_P.Saturation_UpperSat_k;
    } else if (rtb_Bias <= Ctrl_P.Saturation_LowerSat_e) {
      rtb_Sum_p = Ctrl_P.Saturation_LowerSat_e;
    } else {
      rtb_Sum_p = rtb_Bias;
    }

    /* End of Saturate: '<S46>/Saturation' */

    /* Gain: '<S37>/Scale pitch' */
    rtb_Saturation_i = Ctrl_P.Scalepitch_Gain_i * rtb_Sum_p;

    /* Sum: '<S5>/Add5' */
    rtb_Saturation_kd = (rtb_DLookupTable_l - rtb_Saturation_i) - Kk_idx_0;

    /* Sum: '<S5>/Add6' */
    rtb_Saturation_i = (rtb_Saturation_i + rtb_DLookupTable_l) - Kk_idx_0;

    /* Saturate: '<S5>/Limit1' */
    if (rtb_Saturation_kd >= Ctrl_P.Limit1_UpperSat_m) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_UpperSat_m;
    } else if (rtb_Saturation_kd <= Ctrl_P.Limit1_LowerSat_h) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_LowerSat_h;
    } else {
      Ctrl_B.PWM2 = rtb_Saturation_kd;
    }

    /* End of Saturate: '<S5>/Limit1' */

    /* Saturate: '<S5>/Limit2' */
    if (rtb_Add4_e >= Ctrl_P.Limit2_UpperSat_g) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_UpperSat_g;
    } else if (rtb_Add4_e <= Ctrl_P.Limit2_LowerSat_n) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_LowerSat_n;
    } else {
      Ctrl_B.PWM3 = rtb_Add4_e;
    }

    /* End of Saturate: '<S5>/Limit2' */

    /* Saturate: '<S5>/Limit3' */
    if (Kk_idx >= Ctrl_P.Limit3_UpperSat_h) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_UpperSat_h;
    } else if (Kk_idx <= Ctrl_P.Limit3_LowerSat_g) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_LowerSat_g;
    } else {
      Ctrl_B.PWM1 = Kk_idx;
    }

    /* End of Saturate: '<S5>/Limit3' */

    /* Saturate: '<S5>/Limit4' */
    if (rtb_Saturation_i >= Ctrl_P.Limit4_UpperSat_f) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_UpperSat_f;
    } else if (rtb_Saturation_i <= Ctrl_P.Limit4_LowerSat_k) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_LowerSat_k;
    } else {
      Ctrl_B.PWM4 = rtb_Saturation_i;
    }

    /* End of Saturate: '<S5>/Limit4' */

    /* Gain: '<S46>/Integral Gain' */
    rtb_FilterCoefficient_p *= Ctrl_P.IntegralGain_Gain_a;

    /* Gain: '<S51>/Integral Gain' */
    rtb_IntegralGain_oq *= Ctrl_P.IntegralGain_Gain_n;

    /* Gain: '<S57>/Integral Gain' */
    rtb_IntegralGain_p0 *= Ctrl_P.IntegralGain_Gain_m5;

    /* Update for DiscreteIntegrator: '<S50>/Filter' */
    Ctrl_DWork.Filter_DSTATE_ed += Ctrl_P.Filter_gainval_m * rtb_Add5_m;

    /* Update for DiscreteIntegrator: '<S55>/Filter' */
    Ctrl_DWork.Filter_DSTATE_dt += Ctrl_P.Filter_gainval_g * rtb_Add6_g;

    /* Update for DiscreteIntegrator: '<S49>/Filter' */
    Ctrl_DWork.Filter_DSTATE_c3 += Ctrl_P.Filter_gainval_mi * rtb_IntegralGain_e;

    /* Update for DiscreteIntegrator: '<S54>/Filter' */
    Ctrl_DWork.Filter_DSTATE_al += Ctrl_P.Filter_gainval_iw *
      rtb_FilterCoefficient_e4;

    /* Update for DiscreteIntegrator: '<S52>/Filter' */
    Ctrl_DWork.Filter_DSTATE_cm += Ctrl_P.Filter_gainval_o *
      rtb_FilterCoefficient_at;

    /* Signum: '<S53>/SignPreSat' */
    if (rtb_Sum_am < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Sum_am > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Sum_am;
    }

    /* Signum: '<S53>/SignPreIntegrator' */
    if (rtb_IntegralGain_oq < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_IntegralGain_oq > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_IntegralGain_oq;
    }

    /* Switch: '<S51>/Switch' incorporates:
     *  Constant: '<S51>/Constant'
     *  Logic: '<S53>/AND'
     *  RelationalOperator: '<S53>/Equal'
     *  RelationalOperator: '<S53>/NotEqual'
     *  Signum: '<S53>/SignPreIntegrator'
     *  Signum: '<S53>/SignPreSat'
     */
    if ((rtb_Sum_am != rtb_Saturation_a) && (Kk_idx == Kk_idx_0)) {
      rtb_IntegralGain_oq = Ctrl_P.Constant_Value_cn;
    }

    /* End of Switch: '<S51>/Switch' */

    /* Update for DiscreteIntegrator: '<S51>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_k += Ctrl_P.Integrator_gainval_c *
      rtb_IntegralGain_oq;

    /* Update for DiscreteIntegrator: '<S51>/Filter' */
    Ctrl_DWork.Filter_DSTATE_cj += Ctrl_P.Filter_gainval_p *
      rtb_FilterCoefficient_ox;

    /* Signum: '<S59>/SignPreSat' */
    if (rtb_Scaleyaw_o < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Scaleyaw_o > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Scaleyaw_o;
    }

    /* Signum: '<S59>/SignPreIntegrator' */
    if (rtb_IntegralGain_p0 < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_IntegralGain_p0 > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_IntegralGain_p0;
    }

    /* Switch: '<S57>/Switch' incorporates:
     *  Constant: '<S57>/Constant'
     *  Logic: '<S59>/AND'
     *  RelationalOperator: '<S59>/Equal'
     *  RelationalOperator: '<S59>/NotEqual'
     *  Signum: '<S59>/SignPreIntegrator'
     *  Signum: '<S59>/SignPreSat'
     */
    if ((rtb_Scaleyaw_o != rtb_Add3_f) && (Kk_idx == Kk_idx_0)) {
      rtb_IntegralGain_p0 = Ctrl_P.Constant_Value_d;
    }

    /* End of Switch: '<S57>/Switch' */

    /* Update for DiscreteIntegrator: '<S57>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_e += Ctrl_P.Integrator_gainval_p *
      rtb_IntegralGain_p0;

    /* Update for DiscreteIntegrator: '<S47>/Filter' */
    Ctrl_DWork.Filter_DSTATE_ds += Ctrl_P.Filter_gainval_io * rtb_Bias1;

    /* Signum: '<S48>/SignPreSat' */
    if (rtb_Bias < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_Bias > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_Bias;
    }

    /* Signum: '<S48>/SignPreIntegrator' */
    if (rtb_FilterCoefficient_p < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_FilterCoefficient_p > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_FilterCoefficient_p;
    }

    /* Switch: '<S46>/Switch' incorporates:
     *  Constant: '<S46>/Constant'
     *  Logic: '<S48>/AND'
     *  RelationalOperator: '<S48>/Equal'
     *  RelationalOperator: '<S48>/NotEqual'
     *  Signum: '<S48>/SignPreIntegrator'
     *  Signum: '<S48>/SignPreSat'
     */
    if ((rtb_Bias != rtb_Sum_p) && (Kk_idx_0 == Kk_idx)) {
      rtb_FilterCoefficient_p = Ctrl_P.Constant_Value_c;
    }

    /* End of Switch: '<S46>/Switch' */

    /* Update for DiscreteIntegrator: '<S46>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_kk += Ctrl_P.Integrator_gainval_e *
      rtb_FilterCoefficient_p;

    /* Update for DiscreteIntegrator: '<S46>/Filter' */
    Ctrl_DWork.Filter_DSTATE_n += Ctrl_P.Filter_gainval_b * rtb_Bias2;
  } else {
    if (Ctrl_DWork.AutoCtrl_MODE) {
      Ctrl_DWork.AutoCtrl_MODE = FALSE;
    }
  }

  /* End of Outputs for SubSystem: '<S1>/AutoCtrl' */

  /* Outputs for Enabled SubSystem: '<S1>/Off' incorporates:
   *  EnablePort: '<S7>/Enable'
   */
  if (Ctrl_B.CtrlOff) {
    /* Constant: '<S7>/Constant1' */
    Ctrl_B.PWM2 = Ctrl_P.Constant1_Value;

    /* Constant: '<S7>/Constant2' */
    Ctrl_B.PWM1 = Ctrl_P.Constant2_Value;

    /* Constant: '<S7>/Constant3' */
    Ctrl_B.PWM3 = Ctrl_P.Constant3_Value;

    /* Constant: '<S7>/Constant4' */
    Ctrl_B.PWM4 = Ctrl_P.Constant4_Value;
  }

  /* End of Outputs for SubSystem: '<S1>/Off' */

  /* Outputs for Enabled SubSystem: '<S1>/RateCtrl' incorporates:
   *  EnablePort: '<S8>/Enable'
   */
  if (Ctrl_B.CtrlRate) {
    if (!Ctrl_DWork.RateCtrl_MODE) {
      /* InitializeConditions for DiscreteIntegrator: '<S63>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_jw = Ctrl_P.Integrator_IC_p;

      /* InitializeConditions for DiscreteIntegrator: '<S63>/Filter' */
      Ctrl_DWork.Filter_DSTATE_a = Ctrl_P.Filter_IC_ad;

      /* InitializeConditions for DiscreteIntegrator: '<S67>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_g = Ctrl_P.Integrator_IC_kr;

      /* InitializeConditions for DiscreteIntegrator: '<S65>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_gl = Ctrl_P.Integrator_IC_ms;

      /* InitializeConditions for DiscreteIntegrator: '<S65>/Filter' */
      Ctrl_DWork.Filter_DSTATE_f = Ctrl_P.Filter_IC_g;
      Ctrl_DWork.RateCtrl_MODE = TRUE;
    }

    /* Lookup_n-D: '<S8>/1-D Lookup Table' incorporates:
     *  Inport: '<Root>/Throttle'
     */
    Kk_idx = look1_iflf_binlxpw(Ctrl_U.Throttle, Ctrl_P.DLookupTable_bp01Data_f,
      Ctrl_P.DLookupTable_tableData_o, 3UL);

    /* Sum: '<S60>/Sum' incorporates:
     *  Gain: '<S60>/Scale roll2'
     *  Inport: '<Root>/Roll'
     *  Inport: '<Root>/omega'
     */
    rtb_Bias1 = Ctrl_P.Scaleroll2_Gain_j * Ctrl_U.Roll - Ctrl_U.omega[0];

    /* Gain: '<S63>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S63>/Filter'
     *  Gain: '<S63>/Derivative Gain'
     *  Sum: '<S63>/SumD'
     */
    rtb_Bias2 = (Ctrl_P.DerivativeGain_Gain_p * rtb_Bias1 -
                 Ctrl_DWork.Filter_DSTATE_a) * Ctrl_P.FilterCoefficient_Gain_m;

    /* Sum: '<S63>/Sum' incorporates:
     *  DiscreteIntegrator: '<S63>/Integrator'
     *  Gain: '<S63>/Proportional Gain'
     */
    rtb_Bias = (Ctrl_P.ProportionalGain_Gain_i * rtb_Bias1 +
                Ctrl_DWork.Integrator_DSTATE_jw) + rtb_Bias2;

    /* Saturate: '<S63>/Saturation' */
    if (rtb_Bias >= Ctrl_P.Saturation_UpperSat_pl) {
      rtb_Saturation_i = Ctrl_P.Saturation_UpperSat_pl;
    } else if (rtb_Bias <= Ctrl_P.Saturation_LowerSat_fc) {
      rtb_Saturation_i = Ctrl_P.Saturation_LowerSat_fc;
    } else {
      rtb_Saturation_i = rtb_Bias;
    }

    /* End of Saturate: '<S63>/Saturation' */

    /* Gain: '<S60>/Scale roll' */
    rtb_Add5_m = Ctrl_P.Scaleroll_Gain_p * rtb_Saturation_i;

    /* Sum: '<S62>/Sum' incorporates:
     *  Gain: '<S62>/Scale roll2'
     *  Inport: '<Root>/Yaw'
     *  Inport: '<Root>/omega'
     */
    rtb_Sum_p = Ctrl_P.Scaleroll2_Gain_nk * Ctrl_U.Yaw - Ctrl_U.omega[2];

    /* Sum: '<S67>/Sum' incorporates:
     *  DiscreteIntegrator: '<S67>/Integrator'
     *  Gain: '<S67>/Proportional Gain'
     */
    rtb_Saturation_kd = Ctrl_P.ProportionalGain_Gain_oz * rtb_Sum_p +
      Ctrl_DWork.Integrator_DSTATE_g;

    /* Saturate: '<S67>/Saturation' */
    if (rtb_Saturation_kd >= Ctrl_P.Saturation_UpperSat_lo) {
      rtb_Add6_g = Ctrl_P.Saturation_UpperSat_lo;
    } else if (rtb_Saturation_kd <= Ctrl_P.Saturation_LowerSat_h) {
      rtb_Add6_g = Ctrl_P.Saturation_LowerSat_h;
    } else {
      rtb_Add6_g = rtb_Saturation_kd;
    }

    /* End of Saturate: '<S67>/Saturation' */

    /* Gain: '<S62>/Scale yaw' */
    rtb_FilterCoefficient_p = Ctrl_P.Scaleyaw_Gain_k * rtb_Add6_g;

    /* Sum: '<S8>/Add3' */
    rtb_IntegralGain_e = (Kk_idx - rtb_Add5_m) + rtb_FilterCoefficient_p;

    /* Sum: '<S8>/Add4' */
    rtb_Add5_m = (rtb_Add5_m + Kk_idx) + rtb_FilterCoefficient_p;

    /* Sum: '<S61>/Sum' incorporates:
     *  Gain: '<S61>/Scale roll2'
     *  Inport: '<Root>/Pitch'
     *  Inport: '<Root>/omega'
     */
    rtb_FilterCoefficient_e4 = Ctrl_P.Scaleroll2_Gain_o * Ctrl_U.Pitch -
      Ctrl_U.omega[1];

    /* Gain: '<S65>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S65>/Filter'
     *  Gain: '<S65>/Derivative Gain'
     *  Sum: '<S65>/SumD'
     */
    rtb_IntegralGain_oq = (Ctrl_P.DerivativeGain_Gain_gr *
      rtb_FilterCoefficient_e4 - Ctrl_DWork.Filter_DSTATE_f) *
      Ctrl_P.FilterCoefficient_Gain_ds;

    /* Sum: '<S65>/Sum' incorporates:
     *  DiscreteIntegrator: '<S65>/Integrator'
     *  Gain: '<S65>/Proportional Gain'
     */
    rtb_FilterCoefficient_at = (Ctrl_P.ProportionalGain_Gain_a0 *
      rtb_FilterCoefficient_e4 + Ctrl_DWork.Integrator_DSTATE_gl) +
      rtb_IntegralGain_oq;

    /* Saturate: '<S65>/Saturation' */
    if (rtb_FilterCoefficient_at >= Ctrl_P.Saturation_UpperSat_a2) {
      rtb_FilterCoefficient_ox = Ctrl_P.Saturation_UpperSat_a2;
    } else if (rtb_FilterCoefficient_at <= Ctrl_P.Saturation_LowerSat_ed) {
      rtb_FilterCoefficient_ox = Ctrl_P.Saturation_LowerSat_ed;
    } else {
      rtb_FilterCoefficient_ox = rtb_FilterCoefficient_at;
    }

    /* End of Saturate: '<S65>/Saturation' */

    /* Gain: '<S61>/Scale pitch' */
    rtb_Sum_am = Ctrl_P.Scalepitch_Gain_p * rtb_FilterCoefficient_ox;

    /* Sum: '<S8>/Add5' */
    rtb_Saturation_a = (Kk_idx - rtb_Sum_am) - rtb_FilterCoefficient_p;

    /* Sum: '<S8>/Add6' */
    rtb_Sum_am = (rtb_Sum_am + Kk_idx) - rtb_FilterCoefficient_p;

    /* Saturate: '<S8>/Limit1' */
    if (rtb_Saturation_a >= Ctrl_P.Limit1_UpperSat_o) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_UpperSat_o;
    } else if (rtb_Saturation_a <= Ctrl_P.Limit1_LowerSat_d) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_LowerSat_d;
    } else {
      Ctrl_B.PWM2 = rtb_Saturation_a;
    }

    /* End of Saturate: '<S8>/Limit1' */

    /* Saturate: '<S8>/Limit2' */
    if (rtb_Add5_m >= Ctrl_P.Limit2_UpperSat_l) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_UpperSat_l;
    } else if (rtb_Add5_m <= Ctrl_P.Limit2_LowerSat_c) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_LowerSat_c;
    } else {
      Ctrl_B.PWM3 = rtb_Add5_m;
    }

    /* End of Saturate: '<S8>/Limit2' */

    /* Saturate: '<S8>/Limit3' */
    if (rtb_IntegralGain_e >= Ctrl_P.Limit3_UpperSat_e) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_UpperSat_e;
    } else if (rtb_IntegralGain_e <= Ctrl_P.Limit3_LowerSat_b) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_LowerSat_b;
    } else {
      Ctrl_B.PWM1 = rtb_IntegralGain_e;
    }

    /* End of Saturate: '<S8>/Limit3' */

    /* Saturate: '<S8>/Limit4' */
    if (rtb_Sum_am >= Ctrl_P.Limit4_UpperSat_l) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_UpperSat_l;
    } else if (rtb_Sum_am <= Ctrl_P.Limit4_LowerSat_a) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_LowerSat_a;
    } else {
      Ctrl_B.PWM4 = rtb_Sum_am;
    }

    /* End of Saturate: '<S8>/Limit4' */

    /* Gain: '<S63>/Integral Gain' */
    rtb_Bias1 *= Ctrl_P.IntegralGain_Gain_m0;

    /* Gain: '<S65>/Integral Gain' */
    rtb_FilterCoefficient_e4 *= Ctrl_P.IntegralGain_Gain_f;

    /* Gain: '<S67>/Integral Gain' */
    rtb_Sum_p *= Ctrl_P.IntegralGain_Gain_j;

    /* Signum: '<S64>/SignPreSat' */
    if (rtb_Bias < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_Bias > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_Bias;
    }

    /* Signum: '<S64>/SignPreIntegrator' */
    if (rtb_Bias1 < 0.0F) {
      rtb_DLookupTable_l = -1.0F;
    } else if (rtb_Bias1 > 0.0F) {
      rtb_DLookupTable_l = 1.0F;
    } else {
      rtb_DLookupTable_l = rtb_Bias1;
    }

    /* Switch: '<S63>/Switch' incorporates:
     *  Constant: '<S63>/Constant'
     *  Logic: '<S64>/AND'
     *  RelationalOperator: '<S64>/Equal'
     *  RelationalOperator: '<S64>/NotEqual'
     *  Signum: '<S64>/SignPreIntegrator'
     *  Signum: '<S64>/SignPreSat'
     */
    if ((rtb_Bias != rtb_Saturation_i) && (Kk_idx_0 == rtb_DLookupTable_l)) {
      rtb_Bias1 = Ctrl_P.Constant_Value_m;
    }

    /* End of Switch: '<S63>/Switch' */

    /* Update for DiscreteIntegrator: '<S63>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_jw += Ctrl_P.Integrator_gainval_b * rtb_Bias1;

    /* Update for DiscreteIntegrator: '<S63>/Filter' */
    Ctrl_DWork.Filter_DSTATE_a += Ctrl_P.Filter_gainval_d * rtb_Bias2;

    /* Signum: '<S68>/SignPreSat' */
    if (rtb_Saturation_kd < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_Saturation_kd > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_Saturation_kd;
    }

    /* Signum: '<S68>/SignPreIntegrator' */
    if (rtb_Sum_p < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Sum_p > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Sum_p;
    }

    /* Switch: '<S67>/Switch' incorporates:
     *  Constant: '<S67>/Constant'
     *  Logic: '<S68>/AND'
     *  RelationalOperator: '<S68>/Equal'
     *  RelationalOperator: '<S68>/NotEqual'
     *  Signum: '<S68>/SignPreIntegrator'
     *  Signum: '<S68>/SignPreSat'
     */
    if ((rtb_Saturation_kd != rtb_Add6_g) && (Kk_idx_0 == Kk_idx)) {
      rtb_Sum_p = Ctrl_P.Constant_Value_k;
    }

    /* End of Switch: '<S67>/Switch' */

    /* Update for DiscreteIntegrator: '<S67>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_g += Ctrl_P.Integrator_gainval_io * rtb_Sum_p;

    /* Signum: '<S66>/SignPreSat' */
    if (rtb_FilterCoefficient_at < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_FilterCoefficient_at > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_FilterCoefficient_at;
    }

    /* Signum: '<S66>/SignPreIntegrator' */
    if (rtb_FilterCoefficient_e4 < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_FilterCoefficient_e4 > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_FilterCoefficient_e4;
    }

    /* Switch: '<S65>/Switch' incorporates:
     *  Constant: '<S65>/Constant'
     *  Logic: '<S66>/AND'
     *  RelationalOperator: '<S66>/Equal'
     *  RelationalOperator: '<S66>/NotEqual'
     *  Signum: '<S66>/SignPreIntegrator'
     *  Signum: '<S66>/SignPreSat'
     */
    if ((rtb_FilterCoefficient_at != rtb_FilterCoefficient_ox) && (Kk_idx ==
         Kk_idx_0)) {
      rtb_FilterCoefficient_e4 = Ctrl_P.Constant_Value_mm;
    }

    /* End of Switch: '<S65>/Switch' */

    /* Update for DiscreteIntegrator: '<S65>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_gl += Ctrl_P.Integrator_gainval_o *
      rtb_FilterCoefficient_e4;

    /* Update for DiscreteIntegrator: '<S65>/Filter' */
    Ctrl_DWork.Filter_DSTATE_f += Ctrl_P.Filter_gainval_ie * rtb_IntegralGain_oq;
  } else {
    if (Ctrl_DWork.RateCtrl_MODE) {
      Ctrl_DWork.RateCtrl_MODE = FALSE;
    }
  }

  /* End of Outputs for SubSystem: '<S1>/RateCtrl' */

  /* Outputs for Enabled SubSystem: '<S1>/RollPitchCtrl' incorporates:
   *  EnablePort: '<S9>/Enable'
   */
  if (Ctrl_B.CtrlRollPitch) {
    if (!Ctrl_DWork.RollPitchCtrl_MODE) {
      /* InitializeConditions for DiscreteIntegrator: '<S73>/Filter' */
      Ctrl_DWork.Filter_DSTATE = Ctrl_P.Filter_IC_k0;

      /* InitializeConditions for DiscreteIntegrator: '<S72>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE = Ctrl_P.Integrator_IC_f;

      /* InitializeConditions for DiscreteIntegrator: '<S72>/Filter' */
      Ctrl_DWork.Filter_DSTATE_d = Ctrl_P.Filter_IC_e;

      /* InitializeConditions for DiscreteIntegrator: '<S78>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_j = Ctrl_P.Integrator_IC_i;

      /* InitializeConditions for DiscreteIntegrator: '<S76>/Filter' */
      Ctrl_DWork.Filter_DSTATE_c = Ctrl_P.Filter_IC_kv;

      /* InitializeConditions for DiscreteIntegrator: '<S75>/Integrator' */
      Ctrl_DWork.Integrator_DSTATE_i = Ctrl_P.Integrator_IC_gk;

      /* InitializeConditions for DiscreteIntegrator: '<S75>/Filter' */
      Ctrl_DWork.Filter_DSTATE_e = Ctrl_P.Filter_IC_es;
      Ctrl_DWork.RollPitchCtrl_MODE = TRUE;
    }

    /* Lookup_n-D: '<S9>/1-D Lookup Table' incorporates:
     *  Inport: '<Root>/Throttle'
     */
    Kk_idx = look1_iflf_binlxpw(Ctrl_U.Throttle, Ctrl_P.DLookupTable_bp01Data_h,
      Ctrl_P.DLookupTable_tableData_c, 3UL);

    /* Sum: '<S69>/Sum1' incorporates:
     *  Gain: '<S69>/Scale roll2'
     *  Inport: '<Root>/RPY'
     *  Inport: '<Root>/Roll'
     */
    rtb_Bias1 = Ctrl_P.Scaleroll2_Gain_d * Ctrl_U.Roll - Ctrl_U.RPY[0];

    /* Gain: '<S73>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S73>/Filter'
     *  Gain: '<S73>/Derivative Gain'
     *  Sum: '<S73>/SumD'
     */
    rtb_Bias2 = (Ctrl_P.DerivativeGain_Gain_m * rtb_Bias1 -
                 Ctrl_DWork.Filter_DSTATE) * Ctrl_P.FilterCoefficient_Gain_f;

    /* Sum: '<S69>/Sum' incorporates:
     *  Gain: '<S73>/Proportional Gain'
     *  Inport: '<Root>/omega'
     *  Sum: '<S73>/Sum'
     */
    rtb_Bias1 = (Ctrl_P.ProportionalGain_Gain_nv * rtb_Bias1 + rtb_Bias2) -
      Ctrl_U.omega[0];

    /* Gain: '<S72>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S72>/Filter'
     *  Gain: '<S72>/Derivative Gain'
     *  Sum: '<S72>/SumD'
     */
    rtb_Bias = (Ctrl_P.DerivativeGain_Gain_b * rtb_Bias1 -
                Ctrl_DWork.Filter_DSTATE_d) * Ctrl_P.FilterCoefficient_Gain_ck;

    /* Sum: '<S72>/Sum' incorporates:
     *  DiscreteIntegrator: '<S72>/Integrator'
     *  Gain: '<S72>/Proportional Gain'
     */
    rtb_Saturation_i = (Ctrl_P.ProportionalGain_Gain_ds * rtb_Bias1 +
                        Ctrl_DWork.Integrator_DSTATE) + rtb_Bias;

    /* Saturate: '<S72>/Saturation' */
    if (rtb_Saturation_i >= Ctrl_P.Saturation_UpperSat_pd) {
      rtb_Add5_m = Ctrl_P.Saturation_UpperSat_pd;
    } else if (rtb_Saturation_i <= Ctrl_P.Saturation_LowerSat_nf) {
      rtb_Add5_m = Ctrl_P.Saturation_LowerSat_nf;
    } else {
      rtb_Add5_m = rtb_Saturation_i;
    }

    /* End of Saturate: '<S72>/Saturation' */

    /* Gain: '<S69>/Scale roll' */
    rtb_Sum_p = Ctrl_P.Scaleroll_Gain_d * rtb_Add5_m;

    /* Sum: '<S71>/Sum' incorporates:
     *  Gain: '<S71>/Scale roll2'
     *  Inport: '<Root>/Yaw'
     *  Inport: '<Root>/omega'
     */
    rtb_Saturation_kd = Ctrl_P.Scaleroll2_Gain_f * Ctrl_U.Yaw - Ctrl_U.omega[2];

    /* Sum: '<S78>/Sum' incorporates:
     *  DiscreteIntegrator: '<S78>/Integrator'
     *  Gain: '<S78>/Proportional Gain'
     */
    rtb_Add6_g = Ctrl_P.ProportionalGain_Gain_l * rtb_Saturation_kd +
      Ctrl_DWork.Integrator_DSTATE_j;

    /* Saturate: '<S78>/Saturation' */
    if (rtb_Add6_g >= Ctrl_P.Saturation_UpperSat_bm) {
      rtb_FilterCoefficient_p = Ctrl_P.Saturation_UpperSat_bm;
    } else if (rtb_Add6_g <= Ctrl_P.Saturation_LowerSat_eu) {
      rtb_FilterCoefficient_p = Ctrl_P.Saturation_LowerSat_eu;
    } else {
      rtb_FilterCoefficient_p = rtb_Add6_g;
    }

    /* End of Saturate: '<S78>/Saturation' */

    /* Gain: '<S71>/Scale yaw' */
    rtb_IntegralGain_e = Ctrl_P.Scaleyaw_Gain_g * rtb_FilterCoefficient_p;

    /* Sum: '<S9>/Add3' */
    rtb_FilterCoefficient_e4 = (Kk_idx - rtb_Sum_p) + rtb_IntegralGain_e;

    /* Sum: '<S9>/Add4' */
    rtb_Sum_p = (rtb_Sum_p + Kk_idx) + rtb_IntegralGain_e;

    /* Sum: '<S70>/Sum1' incorporates:
     *  Gain: '<S70>/Scale pitch1'
     *  Inport: '<Root>/Pitch'
     *  Inport: '<Root>/RPY'
     */
    rtb_IntegralGain_oq = Ctrl_P.Scalepitch1_Gain_d * Ctrl_U.Pitch - Ctrl_U.RPY
      [1];

    /* Gain: '<S76>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S76>/Filter'
     *  Gain: '<S76>/Derivative Gain'
     *  Sum: '<S76>/SumD'
     */
    rtb_FilterCoefficient_at = (Ctrl_P.DerivativeGain_Gain_fg *
      rtb_IntegralGain_oq - Ctrl_DWork.Filter_DSTATE_c) *
      Ctrl_P.FilterCoefficient_Gain_n;

    /* Sum: '<S70>/Sum' incorporates:
     *  Gain: '<S76>/Proportional Gain'
     *  Inport: '<Root>/omega'
     *  Sum: '<S76>/Sum'
     */
    rtb_IntegralGain_oq = (Ctrl_P.ProportionalGain_Gain_ph * rtb_IntegralGain_oq
      + rtb_FilterCoefficient_at) - Ctrl_U.omega[1];

    /* Gain: '<S75>/Filter Coefficient' incorporates:
     *  DiscreteIntegrator: '<S75>/Filter'
     *  Gain: '<S75>/Derivative Gain'
     *  Sum: '<S75>/SumD'
     */
    rtb_FilterCoefficient_ox = (Ctrl_P.DerivativeGain_Gain_c *
      rtb_IntegralGain_oq - Ctrl_DWork.Filter_DSTATE_e) *
      Ctrl_P.FilterCoefficient_Gain_ir;

    /* Sum: '<S75>/Sum' incorporates:
     *  DiscreteIntegrator: '<S75>/Integrator'
     *  Gain: '<S75>/Proportional Gain'
     */
    rtb_Sum_am = (Ctrl_P.ProportionalGain_Gain_oo1 * rtb_IntegralGain_oq +
                  Ctrl_DWork.Integrator_DSTATE_i) + rtb_FilterCoefficient_ox;

    /* Saturate: '<S75>/Saturation' */
    if (rtb_Sum_am >= Ctrl_P.Saturation_UpperSat_fd) {
      rtb_Saturation_a = Ctrl_P.Saturation_UpperSat_fd;
    } else if (rtb_Sum_am <= Ctrl_P.Saturation_LowerSat_l) {
      rtb_Saturation_a = Ctrl_P.Saturation_LowerSat_l;
    } else {
      rtb_Saturation_a = rtb_Sum_am;
    }

    /* End of Saturate: '<S75>/Saturation' */

    /* Gain: '<S70>/Scale pitch' */
    rtb_Add4_e = Ctrl_P.Scalepitch_Gain_m * rtb_Saturation_a;

    /* Sum: '<S9>/Add5' */
    rtb_IntegralGain_p0 = (Kk_idx - rtb_Add4_e) - rtb_IntegralGain_e;

    /* Sum: '<S9>/Add6' */
    rtb_Add4_e = (rtb_Add4_e + Kk_idx) - rtb_IntegralGain_e;

    /* Saturate: '<S9>/Limit1' */
    if (rtb_IntegralGain_p0 >= Ctrl_P.Limit1_UpperSat_a) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_UpperSat_a;
    } else if (rtb_IntegralGain_p0 <= Ctrl_P.Limit1_LowerSat_i) {
      Ctrl_B.PWM2 = Ctrl_P.Limit1_LowerSat_i;
    } else {
      Ctrl_B.PWM2 = rtb_IntegralGain_p0;
    }

    /* End of Saturate: '<S9>/Limit1' */

    /* Saturate: '<S9>/Limit2' */
    if (rtb_Sum_p >= Ctrl_P.Limit2_UpperSat_o) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_UpperSat_o;
    } else if (rtb_Sum_p <= Ctrl_P.Limit2_LowerSat_d) {
      Ctrl_B.PWM3 = Ctrl_P.Limit2_LowerSat_d;
    } else {
      Ctrl_B.PWM3 = rtb_Sum_p;
    }

    /* End of Saturate: '<S9>/Limit2' */

    /* Saturate: '<S9>/Limit3' */
    if (rtb_FilterCoefficient_e4 >= Ctrl_P.Limit3_UpperSat_g) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_UpperSat_g;
    } else if (rtb_FilterCoefficient_e4 <= Ctrl_P.Limit3_LowerSat_a) {
      Ctrl_B.PWM1 = Ctrl_P.Limit3_LowerSat_a;
    } else {
      Ctrl_B.PWM1 = rtb_FilterCoefficient_e4;
    }

    /* End of Saturate: '<S9>/Limit3' */

    /* Saturate: '<S9>/Limit4' */
    if (rtb_Add4_e >= Ctrl_P.Limit4_UpperSat_h) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_UpperSat_h;
    } else if (rtb_Add4_e <= Ctrl_P.Limit4_LowerSat_h) {
      Ctrl_B.PWM4 = Ctrl_P.Limit4_LowerSat_h;
    } else {
      Ctrl_B.PWM4 = rtb_Add4_e;
    }

    /* End of Saturate: '<S9>/Limit4' */

    /* Gain: '<S72>/Integral Gain' */
    rtb_Bias1 *= Ctrl_P.IntegralGain_Gain_is;

    /* Gain: '<S75>/Integral Gain' */
    rtb_IntegralGain_oq *= Ctrl_P.IntegralGain_Gain_k;

    /* Gain: '<S78>/Integral Gain' */
    rtb_Saturation_kd *= Ctrl_P.IntegralGain_Gain_l;

    /* Update for DiscreteIntegrator: '<S73>/Filter' */
    Ctrl_DWork.Filter_DSTATE += Ctrl_P.Filter_gainval_ga * rtb_Bias2;

    /* Signum: '<S74>/SignPreSat' */
    if (rtb_Saturation_i < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Saturation_i > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Saturation_i;
    }

    /* Signum: '<S74>/SignPreIntegrator' */
    if (rtb_Bias1 < 0.0F) {
      rtb_DLookupTable_l = -1.0F;
    } else if (rtb_Bias1 > 0.0F) {
      rtb_DLookupTable_l = 1.0F;
    } else {
      rtb_DLookupTable_l = rtb_Bias1;
    }

    /* Switch: '<S72>/Switch' incorporates:
     *  Constant: '<S72>/Constant'
     *  Logic: '<S74>/AND'
     *  RelationalOperator: '<S74>/Equal'
     *  RelationalOperator: '<S74>/NotEqual'
     *  Signum: '<S74>/SignPreIntegrator'
     *  Signum: '<S74>/SignPreSat'
     */
    if ((rtb_Saturation_i != rtb_Add5_m) && (Kk_idx == rtb_DLookupTable_l)) {
      rtb_Bias1 = Ctrl_P.Constant_Value_a;
    }

    /* End of Switch: '<S72>/Switch' */

    /* Update for DiscreteIntegrator: '<S72>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE += Ctrl_P.Integrator_gainval_i5 * rtb_Bias1;

    /* Update for DiscreteIntegrator: '<S72>/Filter' */
    Ctrl_DWork.Filter_DSTATE_d += Ctrl_P.Filter_gainval_bh * rtb_Bias;

    /* Signum: '<S79>/SignPreSat' */
    if (rtb_Add6_g < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Add6_g > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Add6_g;
    }

    /* Signum: '<S79>/SignPreIntegrator' */
    if (rtb_Saturation_kd < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_Saturation_kd > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_Saturation_kd;
    }

    /* Switch: '<S78>/Switch' incorporates:
     *  Constant: '<S78>/Constant'
     *  Logic: '<S79>/AND'
     *  RelationalOperator: '<S79>/Equal'
     *  RelationalOperator: '<S79>/NotEqual'
     *  Signum: '<S79>/SignPreIntegrator'
     *  Signum: '<S79>/SignPreSat'
     */
    if ((rtb_Add6_g != rtb_FilterCoefficient_p) && (Kk_idx == Kk_idx_0)) {
      rtb_Saturation_kd = Ctrl_P.Constant_Value_my;
    }

    /* End of Switch: '<S78>/Switch' */

    /* Update for DiscreteIntegrator: '<S78>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_j += Ctrl_P.Integrator_gainval_a *
      rtb_Saturation_kd;

    /* Update for DiscreteIntegrator: '<S76>/Filter' */
    Ctrl_DWork.Filter_DSTATE_c += Ctrl_P.Filter_gainval_e3 *
      rtb_FilterCoefficient_at;

    /* Signum: '<S77>/SignPreSat' */
    if (rtb_Sum_am < 0.0F) {
      Kk_idx = -1.0F;
    } else if (rtb_Sum_am > 0.0F) {
      Kk_idx = 1.0F;
    } else {
      Kk_idx = rtb_Sum_am;
    }

    /* Signum: '<S77>/SignPreIntegrator' */
    if (rtb_IntegralGain_oq < 0.0F) {
      Kk_idx_0 = -1.0F;
    } else if (rtb_IntegralGain_oq > 0.0F) {
      Kk_idx_0 = 1.0F;
    } else {
      Kk_idx_0 = rtb_IntegralGain_oq;
    }

    /* Switch: '<S75>/Switch' incorporates:
     *  Constant: '<S75>/Constant'
     *  Logic: '<S77>/AND'
     *  RelationalOperator: '<S77>/Equal'
     *  RelationalOperator: '<S77>/NotEqual'
     *  Signum: '<S77>/SignPreIntegrator'
     *  Signum: '<S77>/SignPreSat'
     */
    if ((rtb_Sum_am != rtb_Saturation_a) && (Kk_idx == Kk_idx_0)) {
      rtb_IntegralGain_oq = Ctrl_P.Constant_Value_b;
    }

    /* End of Switch: '<S75>/Switch' */

    /* Update for DiscreteIntegrator: '<S75>/Integrator' */
    Ctrl_DWork.Integrator_DSTATE_i += Ctrl_P.Integrator_gainval_f *
      rtb_IntegralGain_oq;

    /* Update for DiscreteIntegrator: '<S75>/Filter' */
    Ctrl_DWork.Filter_DSTATE_e += Ctrl_P.Filter_gainval_f *
      rtb_FilterCoefficient_ox;
  } else {
    if (Ctrl_DWork.RollPitchCtrl_MODE) {
      Ctrl_DWork.RollPitchCtrl_MODE = FALSE;
    }
  }

  /* End of Outputs for SubSystem: '<S1>/RollPitchCtrl' */

  /* Update for DiscreteFir: '<S4>/Discrete FIR Filter' incorporates:
   *  Inport: '<Root>/MagXYZ'
   */
  Ctrl_DWork.DiscreteFIRFilter_circBuf--;
  if (Ctrl_DWork.DiscreteFIRFilter_circBuf < 0L) {
    Ctrl_DWork.DiscreteFIRFilter_circBuf = 8L;
  }

  Ctrl_DWork.DiscreteFIRFilter_states[Ctrl_DWork.DiscreteFIRFilter_circBuf] =
    Ctrl_U.MagXYZ[0];

  /* End of Update for DiscreteFir: '<S4>/Discrete FIR Filter' */

  /* Update for DiscreteFir: '<S4>/Discrete FIR Filter1' incorporates:
   *  Inport: '<Root>/MagXYZ'
   */
  Ctrl_DWork.DiscreteFIRFilter1_circBuf--;
  if (Ctrl_DWork.DiscreteFIRFilter1_circBuf < 0L) {
    Ctrl_DWork.DiscreteFIRFilter1_circBuf = 8L;
  }

  Ctrl_DWork.DiscreteFIRFilter1_states[Ctrl_DWork.DiscreteFIRFilter1_circBuf] =
    Ctrl_U.MagXYZ[1];

  /* End of Update for DiscreteFir: '<S4>/Discrete FIR Filter1' */

  /* Update for DiscreteFir: '<S4>/Discrete FIR Filter2' incorporates:
   *  Inport: '<Root>/MagXYZ'
   */
  Ctrl_DWork.DiscreteFIRFilter2_circBuf--;
  if (Ctrl_DWork.DiscreteFIRFilter2_circBuf < 0L) {
    Ctrl_DWork.DiscreteFIRFilter2_circBuf = 8L;
  }

  Ctrl_DWork.DiscreteFIRFilter2_states[Ctrl_DWork.DiscreteFIRFilter2_circBuf] =
    Ctrl_U.MagXYZ[2];

  /* End of Update for DiscreteFir: '<S4>/Discrete FIR Filter2' */
  /* End of Outputs for SubSystem: '<Root>/Ctrl' */

  /* Outport: '<Root>/ActualMode' */
  Ctrl_Y.ActualMode = Ctrl_B.AMode;

  /* Outport: '<Root>/Failed' */
  Ctrl_Y.Failed = Ctrl_B.Failed;

  /* Outport: '<Root>/PWM1' */
  Ctrl_Y.PWM1 = Ctrl_B.PWM1;

  /* Outport: '<Root>/PWM2' */
  Ctrl_Y.PWM2 = Ctrl_B.PWM2;

  /* Outport: '<Root>/PWM3' */
  Ctrl_Y.PWM3 = Ctrl_B.PWM3;

  /* Outport: '<Root>/PWM4' */
  Ctrl_Y.PWM4 = Ctrl_B.PWM4;

  /* Outport: '<Root>/MagYaw' */
  Ctrl_Y.MagYaw = rtb_y;

  /* Outport: '<Root>/AltF' */
  Ctrl_Y.AltF = rtb_AltFilt;

  /* Outport: '<Root>/VertSpeed' */
  Ctrl_Y.VertSpeed = rtb_VertSpeed;
}

/* Model initialize function */
void CtrlModelClass::initialize()
{
  /* Registration code */

  /* initialize error status */
  rtmSetErrorStatus(Ctrl_M, (NULL));

  /* block I/O */
  (void) memset(((void *) &Ctrl_B), 0,
                sizeof(BlockIO_Ctrl));

  /* states (dwork) */
  (void) memset((void *)&Ctrl_DWork, 0,
                sizeof(D_Work_Ctrl));

  /* external inputs */
  (void) memset((void *)&Ctrl_U, 0,
                sizeof(ExternalInputs_Ctrl));

  /* external outputs */
  (void) memset((void *)&Ctrl_Y, 0,
                sizeof(ExternalOutputs_Ctrl));

  /* Start for Atomic SubSystem: '<Root>/Ctrl' */
  /* Start for Enabled SubSystem: '<S1>/AltCtrl' */
  /* InitializeConditions for DiscreteIntegrator: '<S29>/Filter' */
  Ctrl_DWork.Filter_DSTATE_di = Ctrl_P.Filter_IC;

  /* InitializeConditions for DiscreteIntegrator: '<S28>/Filter' */
  Ctrl_DWork.Filter_DSTATE_k = Ctrl_P.Filter_IC_k;

  /* InitializeConditions for DiscreteIntegrator: '<S26>/Filter' */
  Ctrl_DWork.Filter_DSTATE_c3b = Ctrl_P.Filter_IC_d;

  /* InitializeConditions for DiscreteIntegrator: '<S25>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_b = Ctrl_P.Integrator_IC;

  /* InitializeConditions for DiscreteIntegrator: '<S25>/Filter' */
  Ctrl_DWork.Filter_DSTATE_g = Ctrl_P.Filter_IC_i;

  /* InitializeConditions for DiscreteIntegrator: '<S31>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_l = Ctrl_P.Integrator_IC_c;

  /* InitializeConditions for DiscreteIntegrator: '<S23>/Filter' */
  Ctrl_DWork.Filter_DSTATE_m = Ctrl_P.Filter_IC_dg;

  /* InitializeConditions for DiscreteIntegrator: '<S22>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_n = Ctrl_P.Integrator_IC_g;

  /* InitializeConditions for DiscreteIntegrator: '<S22>/Filter' */
  Ctrl_DWork.Filter_DSTATE_fe = Ctrl_P.Filter_IC_ko;

  /* End of Start for SubSystem: '<S1>/AltCtrl' */

  /* Start for Enabled SubSystem: '<S1>/AutoCtrl' */
  /* InitializeConditions for DiscreteIntegrator: '<S50>/Filter' */
  Ctrl_DWork.Filter_DSTATE_ed = Ctrl_P.Filter_IC_j;

  /* InitializeConditions for DiscreteIntegrator: '<S55>/Filter' */
  Ctrl_DWork.Filter_DSTATE_dt = Ctrl_P.Filter_IC_n;

  /* InitializeConditions for DiscreteIntegrator: '<S49>/Filter' */
  Ctrl_DWork.Filter_DSTATE_c3 = Ctrl_P.Filter_IC_a;

  /* InitializeConditions for DiscreteIntegrator: '<S54>/Filter' */
  Ctrl_DWork.Filter_DSTATE_al = Ctrl_P.Filter_IC_c;

  /* InitializeConditions for DiscreteIntegrator: '<S52>/Filter' */
  Ctrl_DWork.Filter_DSTATE_cm = Ctrl_P.Filter_IC_o;

  /* InitializeConditions for DiscreteIntegrator: '<S51>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_k = Ctrl_P.Integrator_IC_m;

  /* InitializeConditions for DiscreteIntegrator: '<S51>/Filter' */
  Ctrl_DWork.Filter_DSTATE_cj = Ctrl_P.Filter_IC_of;

  /* InitializeConditions for DiscreteIntegrator: '<S57>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_e = Ctrl_P.Integrator_IC_k;

  /* InitializeConditions for DiscreteIntegrator: '<S47>/Filter' */
  Ctrl_DWork.Filter_DSTATE_ds = Ctrl_P.Filter_IC_f;

  /* InitializeConditions for DiscreteIntegrator: '<S46>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_kk = Ctrl_P.Integrator_IC_o;

  /* InitializeConditions for DiscreteIntegrator: '<S46>/Filter' */
  Ctrl_DWork.Filter_DSTATE_n = Ctrl_P.Filter_IC_cm;

  /* End of Start for SubSystem: '<S1>/AutoCtrl' */

  /* Start for Enabled SubSystem: '<S1>/Off' */
  /* VirtualOutportStart for Outport: '<S7>/PWMs' */
  Ctrl_B.PWM1 = Ctrl_P.PWMs_Y0[0];
  Ctrl_B.PWM2 = Ctrl_P.PWMs_Y0[1];
  Ctrl_B.PWM3 = Ctrl_P.PWMs_Y0[2];
  Ctrl_B.PWM4 = Ctrl_P.PWMs_Y0[3];

  /* End of Start for SubSystem: '<S1>/Off' */

  /* Start for Enabled SubSystem: '<S1>/RateCtrl' */
  /* InitializeConditions for DiscreteIntegrator: '<S63>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_jw = Ctrl_P.Integrator_IC_p;

  /* InitializeConditions for DiscreteIntegrator: '<S63>/Filter' */
  Ctrl_DWork.Filter_DSTATE_a = Ctrl_P.Filter_IC_ad;

  /* InitializeConditions for DiscreteIntegrator: '<S67>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_g = Ctrl_P.Integrator_IC_kr;

  /* InitializeConditions for DiscreteIntegrator: '<S65>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_gl = Ctrl_P.Integrator_IC_ms;

  /* InitializeConditions for DiscreteIntegrator: '<S65>/Filter' */
  Ctrl_DWork.Filter_DSTATE_f = Ctrl_P.Filter_IC_g;

  /* End of Start for SubSystem: '<S1>/RateCtrl' */

  /* Start for Enabled SubSystem: '<S1>/RollPitchCtrl' */
  /* InitializeConditions for DiscreteIntegrator: '<S73>/Filter' */
  Ctrl_DWork.Filter_DSTATE = Ctrl_P.Filter_IC_k0;

  /* InitializeConditions for DiscreteIntegrator: '<S72>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE = Ctrl_P.Integrator_IC_f;

  /* InitializeConditions for DiscreteIntegrator: '<S72>/Filter' */
  Ctrl_DWork.Filter_DSTATE_d = Ctrl_P.Filter_IC_e;

  /* InitializeConditions for DiscreteIntegrator: '<S78>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_j = Ctrl_P.Integrator_IC_i;

  /* InitializeConditions for DiscreteIntegrator: '<S76>/Filter' */
  Ctrl_DWork.Filter_DSTATE_c = Ctrl_P.Filter_IC_kv;

  /* InitializeConditions for DiscreteIntegrator: '<S75>/Integrator' */
  Ctrl_DWork.Integrator_DSTATE_i = Ctrl_P.Integrator_IC_gk;

  /* InitializeConditions for DiscreteIntegrator: '<S75>/Filter' */
  Ctrl_DWork.Filter_DSTATE_e = Ctrl_P.Filter_IC_es;

  /* End of Start for SubSystem: '<S1>/RollPitchCtrl' */
  /* End of Start for SubSystem: '<Root>/Ctrl' */

  /* Start for Outport: '<Root>/ActualMode' */
  Ctrl_Y.ActualMode = Ctrl_B.AMode;

  /* Start for Outport: '<Root>/Failed' */
  Ctrl_Y.Failed = Ctrl_B.Failed;

  /* Start for Outport: '<Root>/PWM1' */
  Ctrl_Y.PWM1 = Ctrl_B.PWM1;

  /* Start for Outport: '<Root>/PWM2' */
  Ctrl_Y.PWM2 = Ctrl_B.PWM2;

  /* Start for Outport: '<Root>/PWM3' */
  Ctrl_Y.PWM3 = Ctrl_B.PWM3;

  /* Start for Outport: '<Root>/PWM4' */
  Ctrl_Y.PWM4 = Ctrl_B.PWM4;

  {
    int16_T i;

    /* InitializeConditions for Atomic SubSystem: '<Root>/Ctrl' */
    /* InitializeConditions for MATLAB Function: '<S2>/Embedded MATLAB Function2' */
    Ctrl_DWork.Pk[0] = 1.64024994E-9F;
    Ctrl_DWork.Pk[1] = 3.2805E-7F;
    Ctrl_DWork.Pk[2] = 3.2805E-7F;
    Ctrl_DWork.Pk[3] = 6.561E-5F;
    Ctrl_DWork.Xk[0] = 0.0F;
    Ctrl_DWork.Xk[1] = 0.0F;

    /* InitializeConditions for DiscreteFir: '<S4>/Discrete FIR Filter' */
    Ctrl_DWork.DiscreteFIRFilter_circBuf = 0L;

    /* InitializeConditions for DiscreteFir: '<S4>/Discrete FIR Filter1' */
    Ctrl_DWork.DiscreteFIRFilter1_circBuf = 0L;

    /* InitializeConditions for DiscreteFir: '<S4>/Discrete FIR Filter2' */
    Ctrl_DWork.DiscreteFIRFilter2_circBuf = 0L;
    for (i = 0; i < 9; i++) {
      /* InitializeConditions for DiscreteFir: '<S4>/Discrete FIR Filter' */
      Ctrl_DWork.DiscreteFIRFilter_states[i] =
        Ctrl_P.DiscreteFIRFilter_InitialStates;

      /* InitializeConditions for DiscreteFir: '<S4>/Discrete FIR Filter1' */
      Ctrl_DWork.DiscreteFIRFilter1_states[i] =
        Ctrl_P.DiscreteFIRFilter1_InitialState;
      Ctrl_DWork.DiscreteFIRFilter2_states[i] =
        Ctrl_P.DiscreteFIRFilter2_InitialState;
    }

    /* End of InitializeConditions for DiscreteFir: '<S4>/Discrete FIR Filter2' */

    /* InitializeConditions for Chart: '<S1>/Chart' */
    Ctrl_DWork.is_active_SystemLogic = 0U;
    Ctrl_DWork.is_SystemLogic = 0U;
    Ctrl_DWork.is_Online = 0U;
    Ctrl_DWork.is_active_c1_Ctrl = 0U;
    Ctrl_B.AMode = 0UL;
    Ctrl_B.Failed = FALSE;
    Ctrl_B.CtrlOff = FALSE;
    Ctrl_B.CtrlRate = FALSE;
    Ctrl_B.CtrlRollPitch = FALSE;
    Ctrl_B.CtrlAlt = FALSE;
    Ctrl_B.CtrlAuto = FALSE;

    /* End of InitializeConditions for SubSystem: '<Root>/Ctrl' */
  }
}

/* Model terminate function */
void CtrlModelClass::terminate()
{
  /* (no terminate code required) */
}

/* Constructor */
CtrlModelClass::CtrlModelClass()
{
  Parameters_Ctrl Ctrl_P_temp = {
    /*  Computed Parameter: DLookupTable_tableData
     * Referenced by: '<S3>/1-D Lookup Table'
     */
    { 800.0F, 800.0F, 1200.0F, 1700.0F },

    /*  Computed Parameter: DLookupTable_bp01Data
     * Referenced by: '<S3>/1-D Lookup Table'
     */
    { 0.0F, 0.1F, 0.101F, 1.0F },
    -2.0F,                             /* Computed Parameter: VeScaler_Gain
                                        * Referenced by: '<S16>/Ve Scaler'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain
                                        * Referenced by: '<S29>/Proportional Gain'
                                        */
    0.0F,                              /* Computed Parameter: DerivativeGain_Gain
                                        * Referenced by: '<S29>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval
                                        * Referenced by: '<S29>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC
                                        * Referenced by: '<S29>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain
                                        * Referenced by: '<S29>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: Saturation_UpperSat
                                        * Referenced by: '<S29>/Saturation'
                                        */
    -0.3F,                             /* Computed Parameter: Saturation_LowerSat
                                        * Referenced by: '<S29>/Saturation'
                                        */
    2.0F,                              /* Computed Parameter: VeScaler1_Gain
                                        * Referenced by: '<S16>/Ve Scaler1'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_a
                                        * Referenced by: '<S28>/Proportional Gain'
                                        */
    0.0F,                              /* Computed Parameter: DerivativeGain_Gain_i
                                        * Referenced by: '<S28>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_n
                                        * Referenced by: '<S28>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_k
                                        * Referenced by: '<S28>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_i
                                        * Referenced by: '<S28>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: Saturation_UpperSat_n
                                        * Referenced by: '<S28>/Saturation'
                                        */
    -0.3F,                             /* Computed Parameter: Saturation_LowerSat_m
                                        * Referenced by: '<S28>/Saturation'
                                        */
    0.5F,                              /* Computed Parameter: Scaleroll2_Gain
                                        * Referenced by: '<S15>/Scale roll2'
                                        */
    3.0F,                              /* Computed Parameter: ProportionalGain_Gain_c
                                        * Referenced by: '<S26>/Proportional Gain'
                                        */
    -0.15F,                            /* Computed Parameter: DerivativeGain_Gain_h
                                        * Referenced by: '<S26>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_e
                                        * Referenced by: '<S26>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_d
                                        * Referenced by: '<S26>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_is
                                        * Referenced by: '<S26>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_a5
                                        * Referenced by: '<S25>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval
                                        * Referenced by: '<S25>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC
                                        * Referenced by: '<S25>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_e
                                        * Referenced by: '<S25>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_h
                                        * Referenced by: '<S25>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_i
                                        * Referenced by: '<S25>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_e
                                        * Referenced by: '<S25>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_g
                                        * Referenced by: '<S25>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_mp
                                        * Referenced by: '<S25>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleroll_Gain
                                        * Referenced by: '<S15>/Scale roll'
                                        */
    3.14159274F,                       /* Computed Parameter: Scaleroll2_Gain_i
                                        * Referenced by: '<S17>/Scale roll2'
                                        */
    0.5111F,                           /* Computed Parameter: ProportionalGain_Gain_e
                                        * Referenced by: '<S32>/Proportional Gain'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_i
                                        * Referenced by: '<S32>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_n
                                        * Referenced by: '<S32>/Saturation'
                                        */
    2.0F,                              /* Computed Parameter: ProportionalGain_Gain_m
                                        * Referenced by: '<S31>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_i
                                        * Referenced by: '<S31>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_c
                                        * Referenced by: '<S31>/Integrator'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_p
                                        * Referenced by: '<S31>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_nb
                                        * Referenced by: '<S31>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleyaw_Gain
                                        * Referenced by: '<S17>/Scale yaw'
                                        */
    -1.0F,                             /* Computed Parameter: InvertPitchref1_Gain
                                        * Referenced by: '<S16>/Invert Pitch ref1'
                                        */
    0.5F,                              /* Computed Parameter: Scalepitch1_Gain
                                        * Referenced by: '<S14>/Scale pitch1'
                                        */
    3.0F,                              /* Computed Parameter: ProportionalGain_Gain_o
                                        * Referenced by: '<S23>/Proportional Gain'
                                        */
    -0.15F,                            /* Computed Parameter: DerivativeGain_Gain_g
                                        * Referenced by: '<S23>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_i
                                        * Referenced by: '<S23>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_dg
                                        * Referenced by: '<S23>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_j
                                        * Referenced by: '<S23>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_h
                                        * Referenced by: '<S22>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_n
                                        * Referenced by: '<S22>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_g
                                        * Referenced by: '<S22>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_d
                                        * Referenced by: '<S22>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_j
                                        * Referenced by: '<S22>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_ko
                                        * Referenced by: '<S22>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_d
                                        * Referenced by: '<S22>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_gy
                                        * Referenced by: '<S22>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_f
                                        * Referenced by: '<S22>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scalepitch_Gain
                                        * Referenced by: '<S14>/Scale pitch'
                                        */
    2000.0F,                           /* Computed Parameter: Limit1_UpperSat
                                        * Referenced by: '<S3>/Limit1'
                                        */
    1000.0F,                           /* Computed Parameter: Limit1_LowerSat
                                        * Referenced by: '<S3>/Limit1'
                                        */
    2000.0F,                           /* Computed Parameter: Limit2_UpperSat
                                        * Referenced by: '<S3>/Limit2'
                                        */
    1000.0F,                           /* Computed Parameter: Limit2_LowerSat
                                        * Referenced by: '<S3>/Limit2'
                                        */
    2000.0F,                           /* Computed Parameter: Limit3_UpperSat
                                        * Referenced by: '<S3>/Limit3'
                                        */
    1000.0F,                           /* Computed Parameter: Limit3_LowerSat
                                        * Referenced by: '<S3>/Limit3'
                                        */
    2000.0F,                           /* Computed Parameter: Limit4_UpperSat
                                        * Referenced by: '<S3>/Limit4'
                                        */
    1000.0F,                           /* Computed Parameter: Limit4_LowerSat
                                        * Referenced by: '<S3>/Limit4'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain
                                        * Referenced by: '<S22>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value
                                        * Referenced by: '<S22>/Constant'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain_i
                                        * Referenced by: '<S25>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_e
                                        * Referenced by: '<S25>/Constant'
                                        */
    2.0F,                              /* Computed Parameter: IntegralGain_Gain_m
                                        * Referenced by: '<S31>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_g
                                        * Referenced by: '<S31>/Constant'
                                        */

    /*  Computed Parameter: DLookupTable_tableData_d
     * Referenced by: '<S5>/1-D Lookup Table'
     */
    { 800.0F, 800.0F, 1200.0F, 1700.0F },

    /*  Computed Parameter: DLookupTable_bp01Data_l
     * Referenced by: '<S5>/1-D Lookup Table'
     */
    { 0.0F, 0.1F, 0.101F, 1.0F },
    0.05F,                             /* Computed Parameter: ProportionalGain_Gain_ot
                                        * Referenced by: '<S50>/Proportional Gain'
                                        */
    0.0F,                              /* Computed Parameter: DerivativeGain_Gain_j
                                        * Referenced by: '<S50>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_m
                                        * Referenced by: '<S50>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_j
                                        * Referenced by: '<S50>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_db
                                        * Referenced by: '<S50>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_b
                                        * Referenced by: '<S50>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_b
                                        * Referenced by: '<S50>/Saturation'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_oo
                                        * Referenced by: '<S55>/Proportional Gain'
                                        */
    0.0F,                              /* Computed Parameter: DerivativeGain_Gain_n
                                        * Referenced by: '<S55>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_g
                                        * Referenced by: '<S55>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_n
                                        * Referenced by: '<S55>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_p
                                        * Referenced by: '<S55>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: Saturation_UpperSat_l
                                        * Referenced by: '<S55>/Saturation'
                                        */
    -0.3F,                             /* Computed Parameter: Saturation_LowerSat_nl
                                        * Referenced by: '<S55>/Saturation'
                                        */
    0.05F,                             /* Computed Parameter: ProportionalGain_Gain_ee
                                        * Referenced by: '<S49>/Proportional Gain'
                                        */
    0.0F,                              /* Computed Parameter: DerivativeGain_Gain_hy
                                        * Referenced by: '<S49>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_mi
                                        * Referenced by: '<S49>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_a
                                        * Referenced by: '<S49>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_b
                                        * Referenced by: '<S49>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_lj
                                        * Referenced by: '<S49>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_na
                                        * Referenced by: '<S49>/Saturation'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_n
                                        * Referenced by: '<S54>/Proportional Gain'
                                        */
    0.0F,                              /* Computed Parameter: DerivativeGain_Gain_nj
                                        * Referenced by: '<S54>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_iw
                                        * Referenced by: '<S54>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_c
                                        * Referenced by: '<S54>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_iw
                                        * Referenced by: '<S54>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: Saturation_UpperSat_a
                                        * Referenced by: '<S54>/Saturation'
                                        */
    -0.3F,                             /* Computed Parameter: Saturation_LowerSat_d
                                        * Referenced by: '<S54>/Saturation'
                                        */
    0.5F,                              /* Computed Parameter: Scaleroll2_Gain_l
                                        * Referenced by: '<S39>/Scale roll2'
                                        */
    3.0F,                              /* Computed Parameter: ProportionalGain_Gain_hr
                                        * Referenced by: '<S52>/Proportional Gain'
                                        */
    -0.15F,                            /* Computed Parameter: DerivativeGain_Gain_f
                                        * Referenced by: '<S52>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_o
                                        * Referenced by: '<S52>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_o
                                        * Referenced by: '<S52>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_g
                                        * Referenced by: '<S52>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_b
                                        * Referenced by: '<S51>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_c
                                        * Referenced by: '<S51>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_m
                                        * Referenced by: '<S51>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_o
                                        * Referenced by: '<S51>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_p
                                        * Referenced by: '<S51>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_of
                                        * Referenced by: '<S51>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_l
                                        * Referenced by: '<S51>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_l0
                                        * Referenced by: '<S51>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_k
                                        * Referenced by: '<S51>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleroll_Gain_j
                                        * Referenced by: '<S39>/Scale roll'
                                        */
    3.14159274F,                       /* Computed Parameter: Scaleroll2_Gain_n
                                        * Referenced by: '<S41>/Scale roll2'
                                        */
    0.5111F,                           /* Computed Parameter: ProportionalGain_Gain_d
                                        * Referenced by: '<S58>/Proportional Gain'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_f
                                        * Referenced by: '<S58>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_p
                                        * Referenced by: '<S58>/Saturation'
                                        */
    2.0F,                              /* Computed Parameter: ProportionalGain_Gain_p
                                        * Referenced by: '<S57>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_p
                                        * Referenced by: '<S57>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_k
                                        * Referenced by: '<S57>/Integrator'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_m
                                        * Referenced by: '<S57>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_fd
                                        * Referenced by: '<S57>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleyaw_Gain_i
                                        * Referenced by: '<S41>/Scale yaw'
                                        */
    -1.0F,                             /* Computed Parameter: InvertPitchref1_Gain_b
                                        * Referenced by: '<S40>/Invert Pitch ref1'
                                        */
    0.5F,                              /* Computed Parameter: Scalepitch1_Gain_o
                                        * Referenced by: '<S37>/Scale pitch1'
                                        */
    3.0F,                              /* Computed Parameter: ProportionalGain_Gain_f
                                        * Referenced by: '<S47>/Proportional Gain'
                                        */
    -0.15F,                            /* Computed Parameter: DerivativeGain_Gain_e0
                                        * Referenced by: '<S47>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_io
                                        * Referenced by: '<S47>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_f
                                        * Referenced by: '<S47>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_h
                                        * Referenced by: '<S47>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_or
                                        * Referenced by: '<S46>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_e
                                        * Referenced by: '<S46>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_o
                                        * Referenced by: '<S46>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_dl
                                        * Referenced by: '<S46>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_b
                                        * Referenced by: '<S46>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_cm
                                        * Referenced by: '<S46>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_c
                                        * Referenced by: '<S46>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_k
                                        * Referenced by: '<S46>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_e
                                        * Referenced by: '<S46>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scalepitch_Gain_i
                                        * Referenced by: '<S37>/Scale pitch'
                                        */
    2000.0F,                           /* Computed Parameter: Limit1_UpperSat_m
                                        * Referenced by: '<S5>/Limit1'
                                        */
    1000.0F,                           /* Computed Parameter: Limit1_LowerSat_h
                                        * Referenced by: '<S5>/Limit1'
                                        */
    2000.0F,                           /* Computed Parameter: Limit2_UpperSat_g
                                        * Referenced by: '<S5>/Limit2'
                                        */
    1000.0F,                           /* Computed Parameter: Limit2_LowerSat_n
                                        * Referenced by: '<S5>/Limit2'
                                        */
    2000.0F,                           /* Computed Parameter: Limit3_UpperSat_h
                                        * Referenced by: '<S5>/Limit3'
                                        */
    1000.0F,                           /* Computed Parameter: Limit3_LowerSat_g
                                        * Referenced by: '<S5>/Limit3'
                                        */
    2000.0F,                           /* Computed Parameter: Limit4_UpperSat_f
                                        * Referenced by: '<S5>/Limit4'
                                        */
    1000.0F,                           /* Computed Parameter: Limit4_LowerSat_k
                                        * Referenced by: '<S5>/Limit4'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain_a
                                        * Referenced by: '<S46>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_c
                                        * Referenced by: '<S46>/Constant'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain_n
                                        * Referenced by: '<S51>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_cn
                                        * Referenced by: '<S51>/Constant'
                                        */
    2.0F,                              /* Computed Parameter: IntegralGain_Gain_m5
                                        * Referenced by: '<S57>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_d
                                        * Referenced by: '<S57>/Constant'
                                        */

    /*  Computed Parameter: PWMs_Y0
     * Referenced by: '<S7>/PWMs'
     */
    { 1000.0F, 1000.0F },
    1000.0F,                           /* Computed Parameter: Constant1_Value
                                        * Referenced by: '<S7>/Constant1'
                                        */
    1000.0F,                           /* Computed Parameter: Constant2_Value
                                        * Referenced by: '<S7>/Constant2'
                                        */
    1000.0F,                           /* Computed Parameter: Constant3_Value
                                        * Referenced by: '<S7>/Constant3'
                                        */
    1000.0F,                           /* Computed Parameter: Constant4_Value
                                        * Referenced by: '<S7>/Constant4'
                                        */

    /*  Computed Parameter: DLookupTable_tableData_o
     * Referenced by: '<S8>/1-D Lookup Table'
     */
    { 800.0F, 800.0F, 1200.0F, 1700.0F },

    /*  Computed Parameter: DLookupTable_bp01Data_f
     * Referenced by: '<S8>/1-D Lookup Table'
     */
    { 0.0F, 0.1F, 0.101F, 1.0F },
    1.0F,                              /* Computed Parameter: Scaleroll2_Gain_j
                                        * Referenced by: '<S60>/Scale roll2'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_i
                                        * Referenced by: '<S63>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_b
                                        * Referenced by: '<S63>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_p
                                        * Referenced by: '<S63>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_p
                                        * Referenced by: '<S63>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_d
                                        * Referenced by: '<S63>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_ad
                                        * Referenced by: '<S63>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_m
                                        * Referenced by: '<S63>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_pl
                                        * Referenced by: '<S63>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_fc
                                        * Referenced by: '<S63>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleroll_Gain_p
                                        * Referenced by: '<S60>/Scale roll'
                                        */
    1.0F,                              /* Computed Parameter: Scaleroll2_Gain_nk
                                        * Referenced by: '<S62>/Scale roll2'
                                        */
    2.0F,                              /* Computed Parameter: ProportionalGain_Gain_oz
                                        * Referenced by: '<S67>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_io
                                        * Referenced by: '<S67>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_kr
                                        * Referenced by: '<S67>/Integrator'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_lo
                                        * Referenced by: '<S67>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_h
                                        * Referenced by: '<S67>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleyaw_Gain_k
                                        * Referenced by: '<S62>/Scale yaw'
                                        */
    1.0F,                              /* Computed Parameter: Scaleroll2_Gain_o
                                        * Referenced by: '<S61>/Scale roll2'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_a0
                                        * Referenced by: '<S65>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_o
                                        * Referenced by: '<S65>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_ms
                                        * Referenced by: '<S65>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_gr
                                        * Referenced by: '<S65>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_ie
                                        * Referenced by: '<S65>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_g
                                        * Referenced by: '<S65>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_ds
                                        * Referenced by: '<S65>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_a2
                                        * Referenced by: '<S65>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_ed
                                        * Referenced by: '<S65>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scalepitch_Gain_p
                                        * Referenced by: '<S61>/Scale pitch'
                                        */
    2000.0F,                           /* Computed Parameter: Limit1_UpperSat_o
                                        * Referenced by: '<S8>/Limit1'
                                        */
    1000.0F,                           /* Computed Parameter: Limit1_LowerSat_d
                                        * Referenced by: '<S8>/Limit1'
                                        */
    2000.0F,                           /* Computed Parameter: Limit2_UpperSat_l
                                        * Referenced by: '<S8>/Limit2'
                                        */
    1000.0F,                           /* Computed Parameter: Limit2_LowerSat_c
                                        * Referenced by: '<S8>/Limit2'
                                        */
    2000.0F,                           /* Computed Parameter: Limit3_UpperSat_e
                                        * Referenced by: '<S8>/Limit3'
                                        */
    1000.0F,                           /* Computed Parameter: Limit3_LowerSat_b
                                        * Referenced by: '<S8>/Limit3'
                                        */
    2000.0F,                           /* Computed Parameter: Limit4_UpperSat_l
                                        * Referenced by: '<S8>/Limit4'
                                        */
    1000.0F,                           /* Computed Parameter: Limit4_LowerSat_a
                                        * Referenced by: '<S8>/Limit4'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain_m0
                                        * Referenced by: '<S63>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_m
                                        * Referenced by: '<S63>/Constant'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain_f
                                        * Referenced by: '<S65>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_mm
                                        * Referenced by: '<S65>/Constant'
                                        */
    2.0F,                              /* Computed Parameter: IntegralGain_Gain_j
                                        * Referenced by: '<S67>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_k
                                        * Referenced by: '<S67>/Constant'
                                        */

    /*  Computed Parameter: DLookupTable_tableData_c
     * Referenced by: '<S9>/1-D Lookup Table'
     */
    { 800.0F, 800.0F, 1200.0F, 1700.0F },

    /*  Computed Parameter: DLookupTable_bp01Data_h
     * Referenced by: '<S9>/1-D Lookup Table'
     */
    { 0.0F, 0.1F, 0.101F, 1.0F },
    0.5F,                              /* Computed Parameter: Scaleroll2_Gain_d
                                        * Referenced by: '<S69>/Scale roll2'
                                        */
    3.0F,                              /* Computed Parameter: ProportionalGain_Gain_nv
                                        * Referenced by: '<S73>/Proportional Gain'
                                        */
    -0.15F,                            /* Computed Parameter: DerivativeGain_Gain_m
                                        * Referenced by: '<S73>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_ga
                                        * Referenced by: '<S73>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_k0
                                        * Referenced by: '<S73>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_f
                                        * Referenced by: '<S73>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_ds
                                        * Referenced by: '<S72>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_i5
                                        * Referenced by: '<S72>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_f
                                        * Referenced by: '<S72>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_b
                                        * Referenced by: '<S72>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_bh
                                        * Referenced by: '<S72>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_e
                                        * Referenced by: '<S72>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_ck
                                        * Referenced by: '<S72>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_pd
                                        * Referenced by: '<S72>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_nf
                                        * Referenced by: '<S72>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleroll_Gain_d
                                        * Referenced by: '<S69>/Scale roll'
                                        */
    1.0F,                              /* Computed Parameter: Scaleroll2_Gain_f
                                        * Referenced by: '<S71>/Scale roll2'
                                        */
    2.0F,                              /* Computed Parameter: ProportionalGain_Gain_l
                                        * Referenced by: '<S78>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_a
                                        * Referenced by: '<S78>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_i
                                        * Referenced by: '<S78>/Integrator'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_bm
                                        * Referenced by: '<S78>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_eu
                                        * Referenced by: '<S78>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scaleyaw_Gain_g
                                        * Referenced by: '<S71>/Scale yaw'
                                        */
    0.5F,                              /* Computed Parameter: Scalepitch1_Gain_d
                                        * Referenced by: '<S70>/Scale pitch1'
                                        */
    3.0F,                              /* Computed Parameter: ProportionalGain_Gain_ph
                                        * Referenced by: '<S76>/Proportional Gain'
                                        */
    -0.15F,                            /* Computed Parameter: DerivativeGain_Gain_fg
                                        * Referenced by: '<S76>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_e3
                                        * Referenced by: '<S76>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_kv
                                        * Referenced by: '<S76>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_n
                                        * Referenced by: '<S76>/Filter Coefficient'
                                        */
    0.3F,                              /* Computed Parameter: ProportionalGain_Gain_oo1
                                        * Referenced by: '<S75>/Proportional Gain'
                                        */
    0.01F,                             /* Computed Parameter: Integrator_gainval_f
                                        * Referenced by: '<S75>/Integrator'
                                        */
    0.0F,                              /* Computed Parameter: Integrator_IC_gk
                                        * Referenced by: '<S75>/Integrator'
                                        */
    0.03F,                             /* Computed Parameter: DerivativeGain_Gain_c
                                        * Referenced by: '<S75>/Derivative Gain'
                                        */
    0.01F,                             /* Computed Parameter: Filter_gainval_f
                                        * Referenced by: '<S75>/Filter'
                                        */
    0.0F,                              /* Computed Parameter: Filter_IC_es
                                        * Referenced by: '<S75>/Filter'
                                        */
    50.0F,                             /* Computed Parameter: FilterCoefficient_Gain_ir
                                        * Referenced by: '<S75>/Filter Coefficient'
                                        */
    1.0F,                              /* Computed Parameter: Saturation_UpperSat_fd
                                        * Referenced by: '<S75>/Saturation'
                                        */
    -1.0F,                             /* Computed Parameter: Saturation_LowerSat_l
                                        * Referenced by: '<S75>/Saturation'
                                        */
    100.0F,                            /* Computed Parameter: Scalepitch_Gain_m
                                        * Referenced by: '<S70>/Scale pitch'
                                        */
    2000.0F,                           /* Computed Parameter: Limit1_UpperSat_a
                                        * Referenced by: '<S9>/Limit1'
                                        */
    1000.0F,                           /* Computed Parameter: Limit1_LowerSat_i
                                        * Referenced by: '<S9>/Limit1'
                                        */
    2000.0F,                           /* Computed Parameter: Limit2_UpperSat_o
                                        * Referenced by: '<S9>/Limit2'
                                        */
    1000.0F,                           /* Computed Parameter: Limit2_LowerSat_d
                                        * Referenced by: '<S9>/Limit2'
                                        */
    2000.0F,                           /* Computed Parameter: Limit3_UpperSat_g
                                        * Referenced by: '<S9>/Limit3'
                                        */
    1000.0F,                           /* Computed Parameter: Limit3_LowerSat_a
                                        * Referenced by: '<S9>/Limit3'
                                        */
    2000.0F,                           /* Computed Parameter: Limit4_UpperSat_h
                                        * Referenced by: '<S9>/Limit4'
                                        */
    1000.0F,                           /* Computed Parameter: Limit4_LowerSat_h
                                        * Referenced by: '<S9>/Limit4'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain_is
                                        * Referenced by: '<S72>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_a
                                        * Referenced by: '<S72>/Constant'
                                        */
    0.15F,                             /* Computed Parameter: IntegralGain_Gain_k
                                        * Referenced by: '<S75>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_b
                                        * Referenced by: '<S75>/Constant'
                                        */
    2.0F,                              /* Computed Parameter: IntegralGain_Gain_l
                                        * Referenced by: '<S78>/Integral Gain'
                                        */
    0.0F,                              /* Computed Parameter: Constant_Value_my
                                        * Referenced by: '<S78>/Constant'
                                        */
    0.0F,                              /* Computed Parameter: DiscreteFIRFilter_InitialStates
                                        * Referenced by: '<S4>/Discrete FIR Filter'
                                        */

    /*  Computed Parameter: DiscreteFIRFilter_Coefficients
     * Referenced by: '<S4>/Discrete FIR Filter'
     */
    { 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F },
    -0.2765F,                          /* Computed Parameter: Bias2_Bias
                                        * Referenced by: '<S4>/Bias2'
                                        */
    0.0F,                              /* Computed Parameter: DiscreteFIRFilter1_InitialState
                                        * Referenced by: '<S4>/Discrete FIR Filter1'
                                        */

    /*  Computed Parameter: DiscreteFIRFilter1_Coefficients
     * Referenced by: '<S4>/Discrete FIR Filter1'
     */
    { 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F },
    0.04421F,                          /* Computed Parameter: Bias_Bias
                                        * Referenced by: '<S4>/Bias'
                                        */
    0.0F,                              /* Computed Parameter: DiscreteFIRFilter2_InitialState
                                        * Referenced by: '<S4>/Discrete FIR Filter2'
                                        */

    /*  Computed Parameter: DiscreteFIRFilter2_Coefficients
     * Referenced by: '<S4>/Discrete FIR Filter2'
     */
    { 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F, 0.1F },
    0.1049F,                           /* Computed Parameter: Bias1_Bias
                                        * Referenced by: '<S4>/Bias1'
                                        */
    -1.0F                              /* Computed Parameter: Invert_Gain
                                        * Referenced by: '<S4>/Invert'
                                        */
  };                                   /* Modifiable parameters */

  /* Initialize tunable parameters */
  Ctrl_P = Ctrl_P_temp;

  /* Real-Time Model */
  Ctrl_M = &Ctrl_M_;
}

/* Destructor */
CtrlModelClass::~CtrlModelClass()
{
  /* Currently there is no destructor body generated.*/
}

/* Real-Time Model get method */
RT_MODEL_Ctrl * CtrlModelClass::getRTM() const
{
  return Ctrl_M;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
